netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
To: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: <nic_swsd-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>,
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH net-next 3/3] r8152: replace the return value of rtl_ops_init
Date: Mon, 6 Jan 2014 14:39:26 +0800	[thread overview]
Message-ID: <1388990366-8508-4-git-send-email-hayeswang@realtek.com> (raw)
In-Reply-To: <1388990366-8508-1-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>

Replace the boolean value with the error code for the return value
of the rtl_ops_init().

Signed-off-by: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
---
 drivers/net/usb/r8152.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 8615681..06ed043 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2685,10 +2685,10 @@ static void rtl8153_unload(struct r8152 *tp)
 	r8153_power_cut_en(tp, 1);
 }
 
-static bool rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
+static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
 {
 	struct rtl_ops *ops = &tp->rtl_ops;
-	bool ret = true;
+	int ret = -ENODEV;
 
 	switch (id->idVendor) {
 	case VENDOR_ID_REALTEK:
@@ -2699,6 +2699,7 @@ static bool rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
 			ops->disable		= rtl8152_disable;
 			ops->down		= rtl8152_down;
 			ops->unload		= rtl8152_unload;
+			ret = 0;
 			break;
 		case PRODUCT_ID_RTL8153:
 			ops->init		= r8153_init;
@@ -2706,9 +2707,9 @@ static bool rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
 			ops->disable		= rtl8152_disable;
 			ops->down		= rtl8153_down;
 			ops->unload		= rtl8153_unload;
+			ret = 0;
 			break;
 		default:
-			ret = false;
 			break;
 		}
 		break;
@@ -2721,18 +2722,20 @@ static bool rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
 			ops->disable		= rtl8152_disable;
 			ops->down		= rtl8153_down;
 			ops->unload		= rtl8153_unload;
+			ret = 0;
 			break;
 		default:
-			ret = false;
 			break;
 		}
 		break;
 
 	default:
-		ret = false;
 		break;
 	}
 
+	if (ret)
+		netif_err(tp, probe, tp->netdev, "Unknown Device");
+
 	return ret;
 }
 
@@ -2763,10 +2766,9 @@ static int rtl8152_probe(struct usb_interface *intf,
 	tp->netdev = netdev;
 	tp->intf = intf;
 
-	if (!rtl_ops_init(tp, id)) {
-		netif_err(tp, probe, netdev, "Unknown Device");
-		return -ENODEV;
-	}
+	ret = rtl_ops_init(tp, id);
+	if (ret)
+		goto out;
 
 	tasklet_init(&tp->tl, bottom_half, (unsigned long)tp);
 	INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t);
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-01-06  6:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06  6:39 [PATCH net-next 0/3] adjust the code of r8152 Hayes Wang
2014-01-06  6:39 ` [PATCH net-next 1/3] r8152: replace some tabs with spaces Hayes Wang
2014-01-06  6:39 ` [PATCH net-next 2/3] r8152: move the actions of saving the information of the device Hayes Wang
     [not found] ` <1388990366-8508-1-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
2014-01-06  6:39   ` Hayes Wang [this message]
2014-01-06  6:59     ` [PATCH net-next 3/3] r8152: replace the return value of rtl_ops_init Joe Perches
2014-01-06  9:08 ` [PATCH net-next v2 0/3] adjust the code of r8152 Hayes Wang
2014-01-06  9:08   ` [PATCH net-next v2 1/3] r8152: replace some tabs with spaces Hayes Wang
2014-01-06  9:08   ` [PATCH net-next v2 2/3] r8152: move the actions of saving the information of the device Hayes Wang
2014-01-06  9:08   ` [PATCH net-next v2 3/3] r8152: replace the return value of rtl_ops_init Hayes Wang
2014-01-06 21:15   ` [PATCH net-next v2 0/3] adjust the code of r8152 David Miller

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=1388990366-8508-4-git-send-email-hayeswang@realtek.com \
    --to=hayeswang-rasf1irrpzfbdgjk7y7tuq@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nic_swsd-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org \
    /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).