From: Trond Myklebust Date: Tue, 10 Nov 2020 14:41:21 +0000 (-0500) Subject: SUNRPC: Add a helper to return the transport identifier given a netid X-Git-Tag: baikal/mips/sdk5.9~11941^2~48 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=0f418085d2b50a66e83e9e3895f1f881baab24ac;p=kernel.git SUNRPC: Add a helper to return the transport identifier given a netid Signed-off-by: Trond Myklebust --- diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 3ac5037d1c3da..f7b75c72f80e5 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -386,6 +386,7 @@ xprt_disable_swap(struct rpc_xprt *xprt) int xprt_register_transport(struct xprt_class *type); int xprt_unregister_transport(struct xprt_class *type); int xprt_load_transport(const char *); +int xprt_find_transport_ident(const char *); void xprt_wait_for_reply_request_def(struct rpc_task *task); void xprt_wait_for_reply_request_rtt(struct rpc_task *task); void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index bf490d0c98c6a..23452f57d3692 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -219,22 +219,39 @@ xprt_class_find_by_netid(const char *netid) } /** - * xprt_load_transport - load a transport implementation + * xprt_find_transport_ident - convert a netid into a transport identifier * @netid: transport to load * * Returns: - * 0: transport successfully loaded + * > 0: transport identifier * -ENOENT: transport module not available */ -int xprt_load_transport(const char *netid) +int xprt_find_transport_ident(const char *netid) { const struct xprt_class *t; + int ret; t = xprt_class_find_by_netid(netid); if (!t) return -ENOENT; + ret = t->ident; xprt_class_release(t); - return 0; + return ret; +} +EXPORT_SYMBOL_GPL(xprt_find_transport_ident); + +/** + * xprt_load_transport - load a transport implementation + * @netid: transport to load + * + * Returns: + * 0: transport successfully loaded + * -ENOENT: transport module not available + */ +int xprt_load_transport(const char *netid) +{ + int ret = xprt_find_transport_ident(netid); + return ret < 0 ? ret : 0; } EXPORT_SYMBOL_GPL(xprt_load_transport);