2014-07-24 20:13:50

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 1/8] staging: vt6656: Remove flags fMP_POST_READS and fMP_POST_WRITES

MP_IS_READY(fMP_DISCONNECTED) is used to block thread in vnt_tx_context

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 2 --
drivers/staging/vt6656/main_usb.c | 4 ----
drivers/staging/vt6656/usbpipe.c | 2 +-
3 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 6b7bb8c..273c663 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -406,8 +406,6 @@ struct vnt_private {
}

#define fMP_DISCONNECTED 0x00000002
-#define fMP_POST_READS 0x00000100
-#define fMP_POST_WRITES 0x00000200

#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index b99def7..f887bc0 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -552,8 +552,6 @@ static int vnt_start(struct ieee80211_hw *hw)
}

MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
- MP_SET_FLAG(priv, fMP_POST_READS);
- MP_SET_FLAG(priv, fMP_POST_WRITES);

if (device_init_registers(priv) == false) {
dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -601,8 +599,6 @@ static void vnt_stop(struct ieee80211_hw *hw)
ieee80211_stop_queues(hw);

MP_SET_FLAG(priv, fMP_DISCONNECTED);
- MP_CLEAR_FLAG(priv, fMP_POST_WRITES);
- MP_CLEAR_FLAG(priv, fMP_POST_READS);

cancel_delayed_work_sync(&priv->run_command_work);

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 7b050ba..c23a509 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
int status;
struct urb *urb;

- if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) {
+ if (!(MP_IS_READY(priv))) {
context->in_use = false;
return STATUS_RESOURCES;
}
--
2.0.1



2014-07-24 20:14:03

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 5/8] staging: vt6656: use set_bit to set flags

Replacing MP_SET_FLAG

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 1 -
drivers/staging/vt6656/main_usb.c | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index fd7105e..5ac80d8 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -402,7 +402,6 @@ struct vnt_private {
(uVar)++; \
}

-#define MP_SET_FLAG(_M, _F) ((_M)->flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->flags &= ~(_F))
#define MP_TEST_FLAGS(_M, _F) (((_M)->flags & (_F)) == (_F))

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 87feba5..7798221 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -596,7 +596,7 @@ static void vnt_stop(struct ieee80211_hw *hw)

ieee80211_stop_queues(hw);

- MP_SET_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+ set_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);

cancel_delayed_work_sync(&priv->run_command_work);

@@ -1051,7 +1051,7 @@ static void vt6656_disconnect(struct usb_interface *intf)
usb_set_intfdata(intf, NULL);
usb_put_dev(interface_to_usbdev(intf));

- priv->flags |= DEVICE_FLAGS_UNPLUG;
+ set_bit(DEVICE_FLAGS_UNPLUG, &priv->flags);

ieee80211_free_hw(priv->hw);
}
--
2.0.1


2014-07-24 20:14:07

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 8/8] staging: vt6656: use test_bit to check flags status

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/main_usb.c | 2 +-
drivers/staging/vt6656/usbpipe.c | 6 +++---
drivers/staging/vt6656/wcmd.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index d729d94..fdc5c7b 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -591,7 +591,7 @@ static void vnt_stop(struct ieee80211_hw *hw)
/* clear all keys */
priv->key_entry_inuse = 0;

- if ((priv->flags & DEVICE_FLAGS_UNPLUG) == false)
+ if (!test_bit(DEVICE_FLAGS_UNPLUG, &priv->flags))
vnt_mac_shutdown(priv);

ieee80211_stop_queues(hw);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index b2722b9..f1969fe 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -52,7 +52,7 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
{
int status = 0;

- if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+ if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
return STATUS_FAILURE;

mutex_lock(&priv->usb_lock);
@@ -80,7 +80,7 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
{
int status;

- if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+ if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
return STATUS_FAILURE;

mutex_lock(&priv->usb_lock);
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
int status;
struct urb *urb;

- if (priv->flags & DEVICE_FLAGS_DISCONNECTED) {
+ if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
context->in_use = false;
return STATUS_RESOURCES;
}
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index e5330e3..8f6417bc 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -97,7 +97,7 @@ void vnt_run_command(struct work_struct *work)
struct vnt_private *priv =
container_of(work, struct vnt_private, run_command_work.work);

- if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+ if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
return;

if (priv->cmd_running != true)
--
2.0.1


2014-07-24 20:14:01

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 4/8] staging: vt6656: struct vnt_private merge flag and macros

merge u32 flag into unsigned long Flags

Replacing fMP_DISCONNECTED with DEVICE_FLAGS_DISCONNECTED

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 14 ++++++--------
drivers/staging/vt6656/main_usb.c | 6 +++---
drivers/staging/vt6656/usbpipe.c | 6 +++---
drivers/staging/vt6656/wcmd.c | 2 +-
4 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index ac4c748..fd7105e 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -262,7 +262,8 @@ enum {
};

/* flags for options */
-#define DEVICE_FLAGS_UNPLUG 0x00000001UL
+#define DEVICE_FLAGS_UNPLUG BIT(0)
+#define DEVICE_FLAGS_DISCONNECTED BIT(1)

struct vnt_private {
/* mac80211 */
@@ -281,8 +282,7 @@ struct vnt_private {
spinlock_t lock;
struct mutex usb_lock;

- u32 flags;
- unsigned long Flags;
+ unsigned long flags;

/* USB */
struct urb *interrupt_urb;
@@ -402,11 +402,9 @@ struct vnt_private {
(uVar)++; \
}

-#define fMP_DISCONNECTED 0x00000002
-
-#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
-#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
-#define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
+#define MP_SET_FLAG(_M, _F) ((_M)->flags |= (_F))
+#define MP_CLEAR_FLAG(_M, _F) ((_M)->flags &= ~(_F))
+#define MP_TEST_FLAGS(_M, _F) (((_M)->flags & (_F)) == (_F))

int vnt_init(struct vnt_private *priv);

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 3cfbd31..87feba5 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -551,7 +551,7 @@ static int vnt_start(struct ieee80211_hw *hw)
return -ENOMEM;
}

- MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
+ MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);

if (device_init_registers(priv) == false) {
dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -596,7 +596,7 @@ static void vnt_stop(struct ieee80211_hw *hw)

ieee80211_stop_queues(hw);

- MP_SET_FLAG(priv, fMP_DISCONNECTED);
+ MP_SET_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);

cancel_delayed_work_sync(&priv->run_command_work);

@@ -1025,7 +1025,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)

usb_device_reset(priv);

- MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
+ MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
vnt_reset_command_timer(priv);

vnt_schedule_command(priv, WLAN_CMD_INIT_MAC80211);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index ab95a07..b2722b9 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -52,7 +52,7 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
{
int status = 0;

- if (priv->Flags & fMP_DISCONNECTED)
+ if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
return STATUS_FAILURE;

mutex_lock(&priv->usb_lock);
@@ -80,7 +80,7 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
{
int status;

- if (priv->Flags & fMP_DISCONNECTED)
+ if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
return STATUS_FAILURE;

mutex_lock(&priv->usb_lock);
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
int status;
struct urb *urb;

- if (priv->Flags & fMP_DISCONNECTED) {
+ if (priv->flags & DEVICE_FLAGS_DISCONNECTED) {
context->in_use = false;
return STATUS_RESOURCES;
}
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index e4a5e2b..e5330e3 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -97,7 +97,7 @@ void vnt_run_command(struct work_struct *work)
struct vnt_private *priv =
container_of(work, struct vnt_private, run_command_work.work);

- if (priv->Flags & fMP_DISCONNECTED)
+ if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
return;

if (priv->cmd_running != true)
--
2.0.1


2014-07-24 20:14:05

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 7/8] staging: vt6656: Remove unused macro MP_TEST_FLAGS

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 21f810e..2ec086c 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -402,8 +402,6 @@ struct vnt_private {
(uVar)++; \
}

-#define MP_TEST_FLAGS(_M, _F) (((_M)->flags & (_F)) == (_F))
-
int vnt_init(struct vnt_private *priv);

#endif
--
2.0.1


2014-07-24 20:14:03

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 6/8] staging: vt6656: use clear_bit to remove device flag

Replacing MP_CLEAR_FLAG

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 1 -
drivers/staging/vt6656/main_usb.c | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 5ac80d8..21f810e 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -402,7 +402,6 @@ struct vnt_private {
(uVar)++; \
}

-#define MP_CLEAR_FLAG(_M, _F) ((_M)->flags &= ~(_F))
#define MP_TEST_FLAGS(_M, _F) (((_M)->flags & (_F)) == (_F))

int vnt_init(struct vnt_private *priv);
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 7798221..d729d94 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -551,7 +551,7 @@ static int vnt_start(struct ieee80211_hw *hw)
return -ENOMEM;
}

- MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+ clear_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);

if (device_init_registers(priv) == false) {
dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -1025,7 +1025,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)

usb_device_reset(priv);

- MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+ clear_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);
vnt_reset_command_timer(priv);

vnt_schedule_command(priv, WLAN_CMD_INIT_MAC80211);
--
2.0.1


2014-07-24 20:13:58

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 3/8] staging: vt6656: Remove unsed macro DEVICE_FLAGS_OPENED

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 3 ---
drivers/staging/vt6656/main_usb.c | 4 ----
2 files changed, 7 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 58fbaab..ac4c748 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -264,9 +264,6 @@ enum {
/* flags for options */
#define DEVICE_FLAGS_UNPLUG 0x00000001UL

-/* flags for driver status */
-#define DEVICE_FLAGS_OPENED 0x00010000UL
-
struct vnt_private {
/* mac80211 */
struct ieee80211_hw *hw;
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index f887bc0..3cfbd31 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -562,8 +562,6 @@ static int vnt_start(struct ieee80211_hw *hw)

vnt_int_start_interrupt(priv);

- priv->flags |= DEVICE_FLAGS_OPENED;
-
ieee80211_wake_queues(hw);

return 0;
@@ -604,8 +602,6 @@ static void vnt_stop(struct ieee80211_hw *hw)

priv->cmd_running = false;

- priv->flags &= ~DEVICE_FLAGS_OPENED;
-
device_free_tx_bufs(priv);
device_free_rx_bufs(priv);
device_free_int_bufs(priv);
--
2.0.1


2014-07-24 20:13:53

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 2/8] staging: vt6656: remove macro MP_IS_READY

Just test FLag and remove not.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 2 --
drivers/staging/vt6656/usbpipe.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 273c663..58fbaab 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -411,8 +411,6 @@ struct vnt_private {
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
#define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))

-#define MP_IS_READY(_M) (((_M)->Flags & fMP_DISCONNECTED) == 0)
-
int vnt_init(struct vnt_private *priv);

#endif
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index c23a509..ab95a07 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
int status;
struct urb *urb;

- if (!(MP_IS_READY(priv))) {
+ if (priv->Flags & fMP_DISCONNECTED) {
context->in_use = false;
return STATUS_RESOURCES;
}
--
2.0.1