From: Alison Schofield <amsfield22@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Johnny Kim <johnny.kim@atmel.com>,
Austin Shin <austin.shin@atmel.com>,
Chris Park <chris.park@atmel.com>, Tony Cho <tony.cho@atmel.com>,
Glen Lee <glen.lee@atmel.com>, Leo Kim <leo.kim@atmel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: wilc1000: move initialization of the config values
Date: Thu, 7 Apr 2016 22:35:24 -0700 [thread overview]
Message-ID: <20160408053515.GA10278@d830.WORKGROUP> (raw)
Move the initialization of the config values so that an uninit'd
mutex is not exposed and to simplify the initialization process.
The code was allocating a structure with a lock, initializing and
taking the lock, setting some values, and then releasing the
lock. If no other thread can get it, then the lock isn't needed.
If another thread can get it, it could find it before the mutex
is initialized.
Make it safe and simple by setting the config values and initializing
their mutex before the kthread is started. No lock/unlock needed.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
---
Note- not verified with hardware.
drivers/staging/wilc1000/host_interface.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 04cbff5..40f3d11 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3410,6 +3410,14 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
init_completion(&hif_drv->comp_get_rssi);
init_completion(&hif_drv->comp_inactive_time);
+ hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
+ hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
+ hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
+ hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
+ hif_drv->cfg_values.curr_tx_rate = AUTORATE;
+
+ mutex_init(&hif_drv->cfg_values_lock);
+
if (clients_count == 0) {
result = wilc_mq_create(&hif_msg_q);
@@ -3435,20 +3443,10 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
- mutex_init(&hif_drv->cfg_values_lock);
- mutex_lock(&hif_drv->cfg_values_lock);
-
hif_drv->hif_state = HOST_IF_IDLE;
- hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
- hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
- hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
- hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
- hif_drv->cfg_values.curr_tx_rate = AUTORATE;
hif_drv->p2p_timeout = 0;
- mutex_unlock(&hif_drv->cfg_values_lock);
-
clients_count++;
return result;
--
2.1.4
next reply other threads:[~2016-04-08 5:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 5:35 Alison Schofield [this message]
2016-04-11 12:24 ` [PATCH] staging: wilc1000: move initialization of the config values Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160408053515.GA10278@d830.WORKGROUP \
--to=amsfield22@gmail.com \
--cc=austin.shin@atmel.com \
--cc=chris.park@atmel.com \
--cc=devel@driverdev.osuosl.org \
--cc=glen.lee@atmel.com \
--cc=gregkh@linuxfoundation.org \
--cc=johnny.kim@atmel.com \
--cc=leo.kim@atmel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=tony.cho@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).