[PATCH] Fixed coding style problems.

2018-06-08 Thread Chris Opperman
This patch fixes a coding style problem in drivers/staging/comedi/drivers.c
and is submitted for task 10 of the eudyptula challenge.
Signed-off-by: Chris Opperman 
---
 drivers/staging/comedi/drivers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d73347..90ee974 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -475,7 +475,8 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice 
*s,
struct comedi_cmd *cmd = &async->cmd;
 
if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
+   unsigned int scans_left =
+   __comedi_nscans_left(s, cmd->stop_arg);
unsigned int scan_pos =
comedi_bytes_to_samples(s, async->scan_progress);
unsigned long long samples_left = 0;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: shortened a long line

2018-06-09 Thread Chris Opperman
Shortened a long line to improve readability in 
drivers/staging/comedi/drivers.c

Signed-off-by: Chris Opperman 
---
 drivers/staging/comedi/drivers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d73347..90ee974 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -475,7 +475,8 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice 
*s,
struct comedi_cmd *cmd = &async->cmd;
 
if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
+   unsigned int scans_left =
+   __comedi_nscans_left(s, cmd->stop_arg);
unsigned int scan_pos =
comedi_bytes_to_samples(s, async->scan_progress);
unsigned long long samples_left = 0;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-09 Thread Chris Opperman
Signed-off-by: Chris Opperman 
---
 drivers/staging/comedi/drivers.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d73347..3207ae2 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -468,26 +468,25 @@ EXPORT_SYMBOL_GPL(comedi_nscans_left);
  * Returns the number of samples remaining to complete the command, or the
  * specified expected number of samples (@nsamples), whichever is fewer.
  */
-unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
- unsigned int nsamples)
+u32 comedi_nsamples_left(struct comedi_subdevice *s, u32 nsamples)
 {
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+   u32 scans_left;
+   u64 samples_left;
 
-   if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
-   unsigned int scan_pos =
-   comedi_bytes_to_samples(s, async->scan_progress);
-   unsigned long long samples_left = 0;
-
-   if (scans_left) {
-   samples_left = ((unsigned long long)scans_left *
-   cmd->scan_end_arg) - scan_pos;
-   }
+   if (cmd->stop_src != TRIG_COUNT)
+   return nsamples;
 
-   if (samples_left < nsamples)
-   nsamples = samples_left;
-   }
+   scans_left = __comedi_nscans_left(s, cmd->stop_arg);
+   if (!scans_left)
+   return 0;
+
+   samples_left = ((u64)scans_left * cmd->scan_end_arg) -
+   comedi_bytes_to_samples(s, async->scan_progress);
+
+   if (samples_left < nsamples)
+   return samples_left;
return nsamples;
 }
 EXPORT_SYMBOL_GPL(comedi_nsamples_left);
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-12 Thread Chris Opperman
Hi Dan,
Thank you for the feedback, I'll update V4 of the patch accordingly
and resend. I'll soon get a hang of the workflow! :)
Best Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-12 Thread Chris Opperman
Changes since v3:
a) Reverted u64 to unsigned long long and u32 to unsigned int.
b) Added patch versioning.
c) Changed type of scans_left to unsigned long long to avoid cast.
d) Clarified and updated changelog.

>8---8<

Improve readability of comedi_nsamples_left:
a) Reduce nesting by using more return statements.
b) Declare variables scans_left and samples_left at start of function.
c) Change type of scans_Left to unsigned long long to avoid cast.

Signed-off-by: Chris Opperman 
---
 drivers/staging/comedi/drivers.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d73347..57dd63d 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice 
*s,
 {
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+   unsigned long long scans_left;
+   unsigned long long samples_left;

-   if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
-   unsigned int scan_pos =
-   comedi_bytes_to_samples(s, async->scan_progress);
-   unsigned long long samples_left = 0;
-
-   if (scans_left) {
-   samples_left = ((unsigned long long)scans_left *
-   cmd->scan_end_arg) - scan_pos;
-   }
+   if (cmd->stop_src != TRIG_COUNT)
+   return nsamples;

-   if (samples_left < nsamples)
-   nsamples = samples_left;
-   }
+   scans_left = __comedi_nscans_left(s, cmd->stop_arg);
+   if (!scans_left)
+   return 0;
+
+   samples_left = scans_left * cmd->scan_end_arg -
+   comedi_bytes_to_samples(s, async->scan_progress);
+
+   if (samples_left < nsamples)
+   return samples_left;
return nsamples;
 }
 EXPORT_SYMBOL_GPL(comedi_nsamples_left);
--
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-13 Thread Chris Opperman
Hi Dan/Ian,

Noted your comments regarding additional text, thanks! Just curious whether 
the "scissors" format given at the link below is valid? 

https://kernelnewbies.org/PatchTipsAndTricks

It is given as an alternative to placing additional text below the
cut-off line.

Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-13 Thread Chris Opperman
Improve readability of comedi_nsamples_left:
a) Reduce nesting by using more return statements.
b) Declare variables scans_left and samples_left at start of function.
c) Change type of scans_Left to unsigned long long to avoid cast.

Signed-off-by: Chris Opperman 
---

Changes v5:
a) Moved additional text to below the cut-off line.

 drivers/staging/comedi/drivers.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d73347..57dd63d 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice 
*s,
 {
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+   unsigned long long scans_left;
+   unsigned long long samples_left;

-   if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
-   unsigned int scan_pos =
-   comedi_bytes_to_samples(s, async->scan_progress);
-   unsigned long long samples_left = 0;
-
-   if (scans_left) {
-   samples_left = ((unsigned long long)scans_left *
-   cmd->scan_end_arg) - scan_pos;
-   }
+   if (cmd->stop_src != TRIG_COUNT)
+   return nsamples;

-   if (samples_left < nsamples)
-   nsamples = samples_left;
-   }
+   scans_left = __comedi_nscans_left(s, cmd->stop_arg);
+   if (!scans_left)
+   return 0;
+
+   samples_left = scans_left * cmd->scan_end_arg -
+   comedi_bytes_to_samples(s, async->scan_progress);
+
+   if (samples_left < nsamples)
+   return samples_left;
return nsamples;
 }
 EXPORT_SYMBOL_GPL(comedi_nsamples_left);
--
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-14 Thread Chris Opperman
Hi Ian,

Thank you! Are there any more steps for me to take to complete this
patch process?

Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] staging: comedi: Improved readability of function comedi_nsamples_left.

2018-06-14 Thread Chris Opperman
Hi Ian/Dan,

In that case I'll stick to the cut-off line format in future. Thanks!

Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: improved readability of function prism2_add_key

2018-06-20 Thread Chris Opperman
Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.
b) Added temporary "key" variable to reduce line length.

Signed-off-by: Chris Opperman 
---

Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.
b) Added temporary "key" variable to reduce line length.

 drivers/staging/wlan-ng/cfg80211.c | 40 +-
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/wlan-ng/cfg80211.c 
b/drivers/staging/wlan-ng/cfg80211.c
index 4291225..b46db65 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -147,41 +147,27 @@ static int prism2_add_key(struct wiphy *wiphy, struct 
net_device *dev,
 {
struct wlandevice *wlandev = dev->ml_priv;
u32 did;
-
-   int err = 0;
-   int result = 0;
+   u32 key;
 
if (key_index >= NUM_WEPKEYS)
return -EINVAL;
 
-   switch (params->cipher) {
-   case WLAN_CIPHER_SUITE_WEP40:
-   case WLAN_CIPHER_SUITE_WEP104:
-   result = prism2_domibset_uint32(wlandev,
-   
DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
-   key_index);
-   if (result)
-   goto exit;
-
-   /* send key to driver */
-   did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 
1);
-
-   result = prism2_domibset_pstr32(wlandev, did,
-   params->key_len, params->key);
-   if (result)
-   goto exit;
-   break;
-
-   default:
+   if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
+   params->cipher != WLAN_CIPHER_SUITE_WEP104) {
pr_debug("Unsupported cipher suite\n");
-   result = 1;
+   return -EFAULT;
}
 
-exit:
-   if (result)
-   err = -EFAULT;
+   key = DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID;
+   if (prism2_domibset_uint32(wlandev, key, key_index))
+   return -EFAULT;
 
-   return err;
+   /* send key to driver */
+   did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
+
+   if (prism2_domibset_pstr32(wlandev, did, params->key_len, params->key))
+   return -EFAULT;
+   return 0;
 }
 
 static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wlan-ng: improved readability of function prism2_add_key

2018-06-20 Thread Chris Opperman
Hi Dan,

I agree completely. I was concerned whether the preprocessor definitions in
p80211metadef.h were named according to some convention as there are
many definitions named similarly there. 

I am considering renaming this specific definition to "p80211_dot11_keyid", 
would that be more acceptable?

Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wlan-ng: improved readability of function prism2_add_key

2018-06-21 Thread Chris Opperman
Hi Dan,
The header also states "DO NOT EDIT OR MODIFY". As you suggested, I
will rather leave this patch for now.

P.S. Please advise if there is anything specific I can help out with, or I'll 
keep looking for more obvious fixes I can make while I'm learning the
ropes.
Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wlan-ng: improved readability of function prism2_add_key

2018-06-22 Thread Chris Opperman
Okay, in that case I will fix and resend the patch.

Kind Regards,
Chris Opperman
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: wlan-ng: improved readability of function prism2_add_key

2018-06-22 Thread Chris Opperman
Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.

Signed-off-by: Chris Opperman 
---
 drivers/staging/wlan-ng/cfg80211.c | 40 +-
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/wlan-ng/cfg80211.c 
b/drivers/staging/wlan-ng/cfg80211.c
index 4291225..8320318 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -148,40 +148,26 @@ static int prism2_add_key(struct wiphy *wiphy, struct 
net_device *dev,
struct wlandevice *wlandev = dev->ml_priv;
u32 did;
 
-   int err = 0;
-   int result = 0;
-
if (key_index >= NUM_WEPKEYS)
return -EINVAL;
 
-   switch (params->cipher) {
-   case WLAN_CIPHER_SUITE_WEP40:
-   case WLAN_CIPHER_SUITE_WEP104:
-   result = prism2_domibset_uint32(wlandev,
-   
DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
-   key_index);
-   if (result)
-   goto exit;
-
-   /* send key to driver */
-   did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 
1);
-
-   result = prism2_domibset_pstr32(wlandev, did,
-   params->key_len, params->key);
-   if (result)
-   goto exit;
-   break;
-
-   default:
+   if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
+   params->cipher != WLAN_CIPHER_SUITE_WEP104) {
pr_debug("Unsupported cipher suite\n");
-   result = 1;
+   return -EFAULT;
}
 
-exit:
-   if (result)
-   err = -EFAULT;
+   if (prism2_domibset_uint32(wlandev,
+  
DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
+  key_index))
+   return -EFAULT;
 
-   return err;
+   /* send key to driver */
+   did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
+
+   if (prism2_domibset_pstr32(wlandev, did, params->key_len, params->key))
+   return -EFAULT;
+   return 0;
 }
 
 static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel