All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: silicom: remove redundant pci_get_drvdata() call
@ 2014-04-23  8:18 Daeseok Youn
  2014-04-23  8:35 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Daeseok Youn @ 2014-04-23  8:18 UTC (permalink / raw)
  To: gregkh; +Cc: rupert, daeseok.youn, chad, yongjun_wei, devel, linux-kernel

The pci_get_drvdata() and checking NULL for dev are
called twice in while loop in is_bypass_dev().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
This patch has an warning from checkpatch.pl.
checkpatch.pl warning:
WARNING: Too many leading tabs - consider code refactoring

 drivers/staging/silicom/bypasslib/bypass.c |   51 ++++++++++++---------------
 1 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/silicom/bypasslib/bypass.c b/drivers/staging/silicom/bypasslib/bypass.c
index 09e00da..a58251f 100644
--- a/drivers/staging/silicom/bypasslib/bypass.c
+++ b/drivers/staging/silicom/bypasslib/bypass.c
@@ -149,38 +149,33 @@ static int is_bypass_dev(int if_index)
 
 	while ((pdev = pci_get_class(PCI_CLASS_NETWORK_ETHERNET << 8, pdev))) {
 		dev = pci_get_drvdata(pdev);
-		if (dev != NULL) {
-			dev = pci_get_drvdata(pdev);
-			if ((dev != NULL) && (dev->ifindex == if_index)) {
-				if ((pdev->vendor == SILICOM_VID) &&
-				    (pdev->device >= SILICOM_BP_PID_MIN) &&
-				    (pdev->device <= SILICOM_BP_PID_MAX)) {
-					goto send_cmd;
-				}
+		if ((dev != NULL) && (dev->ifindex == if_index)) {
+			if ((pdev->vendor == SILICOM_VID) &&
+			    (pdev->device >= SILICOM_BP_PID_MIN) &&
+			    (pdev->device <= SILICOM_BP_PID_MAX)) {
+				goto send_cmd;
+			}
 #if defined(BP_VENDOR_SUPPORT) && defined(ETHTOOL_GDRVINFO)
-				else {
-					struct ethtool_drvinfo info;
-					const struct ethtool_ops *ops =
-					    dev->ethtool_ops;
-					int k = 0;
-
-					if (ops->get_drvinfo) {
-						memset(&info, 0, sizeof(info));
-						info.cmd = ETHTOOL_GDRVINFO;
-						ops->get_drvinfo(dev, &info);
-						for (; bp_desc_array[k]; k++)
-							if (!
-							    (strcmp
-							     (bp_desc_array[k],
-							      info.driver)))
-								goto send_cmd;
-
-					}
+			else {
+				struct ethtool_drvinfo info;
+				const struct ethtool_ops *ops =
+					dev->ethtool_ops;
+				int k = 0;
+
+				if (ops->get_drvinfo) {
+					memset(&info, 0, sizeof(info));
+					info.cmd = ETHTOOL_GDRVINFO;
+					ops->get_drvinfo(dev, &info);
+					for (; bp_desc_array[k]; k++)
+						if (!(strcmp(bp_desc_array[k],
+							     info.driver)))
+							goto send_cmd;
 
 				}
-#endif
-				return -1;
+
 			}
+#endif
+			return -1;
 		}
 	}
  send_cmd:
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: silicom: remove redundant pci_get_drvdata() call
  2014-04-23  8:18 [PATCH] staging: silicom: remove redundant pci_get_drvdata() call Daeseok Youn
@ 2014-04-23  8:35 ` Dan Carpenter
  2014-04-23 11:19   ` DaeSeok Youn
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-04-23  8:35 UTC (permalink / raw)
  To: Daeseok Youn; +Cc: gregkh, devel, linux-kernel, yongjun_wei, rupert

On Wed, Apr 23, 2014 at 05:18:42PM +0900, Daeseok Youn wrote:
> The pci_get_drvdata() and checking NULL for dev are
> called twice in while loop in is_bypass_dev().
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
> This patch has an warning from checkpatch.pl.
> checkpatch.pl warning:
> WARNING: Too many leading tabs - consider code refactoring

No problem.  Those were there and worse before your patch.

If someone wanted to fix these then just reverse every if condition in
the function.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: silicom: remove redundant pci_get_drvdata() call
  2014-04-23  8:35 ` Dan Carpenter
@ 2014-04-23 11:19   ` DaeSeok Youn
  0 siblings, 0 replies; 3+ messages in thread
From: DaeSeok Youn @ 2014-04-23 11:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-kernel, yongjun_wei, rupert

2014-04-23 17:35 GMT+09:00, Dan Carpenter <dan.carpenter@oracle.com>:
> On Wed, Apr 23, 2014 at 05:18:42PM +0900, Daeseok Youn wrote:
>> The pci_get_drvdata() and checking NULL for dev are
>> called twice in while loop in is_bypass_dev().
>>
>> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
>> ---
>> This patch has an warning from checkpatch.pl.
>> checkpatch.pl warning:
>> WARNING: Too many leading tabs - consider code refactoring
>
> No problem.  Those were there and worse before your patch.
>
> If someone wanted to fix these then just reverse every if condition in
> the function.
Ok. Thanks for comment.

Regards,
Daeseok Youn
>
> regards,
> dan carpenter
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-23 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23  8:18 [PATCH] staging: silicom: remove redundant pci_get_drvdata() call Daeseok Youn
2014-04-23  8:35 ` Dan Carpenter
2014-04-23 11:19   ` DaeSeok Youn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.