From 4ac6d7a26d1f3c01c23da4d7611c6dbf5dba4f44 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 21 Feb 2015 04:32:36 +0000 Subject: [PATCH] [PATCH] scst: Drop detect() method There is no need for a detect() method - code that is present in such a method can be moved to module_init(). Hence declare this method obsolete. Leave the detect pointer member in the target template for now for out-of-tree SCST drivers. Signed-off-by: Bart Van Assche with some improvements git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6113 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/fcst.h | 1 - fcst/ft_scst.c | 1 - fcst/ft_sess.c | 9 --------- ibmvstgt/src/ibmvstgt.c | 16 ---------------- iscsi-scst/kernel/iscsi.c | 7 ------- scst/include/scst.h | 2 +- scst/src/scst_main.c | 11 ++++------- scst_local/scst_local.c | 9 --------- srpt/src/ib_srpt.c | 11 ----------- 9 files changed, 5 insertions(+), 62 deletions(-) diff --git a/fcst/fcst.h b/fcst/fcst.h index 6067b84bd..9f2276b01 100644 --- a/fcst/fcst.h +++ b/fcst/fcst.h @@ -147,7 +147,6 @@ int ft_send_xfer_rdy(struct scst_cmd *); void ft_cmd_timeout(struct scst_cmd *); void ft_cmd_free(struct scst_cmd *); void ft_cmd_tm_done(struct scst_mgmt_cmd *); -int ft_tgt_detect(struct scst_tgt_template *); int ft_tgt_release(struct scst_tgt *); int ft_tgt_enable(struct scst_tgt *, bool); bool ft_tgt_enabled(struct scst_tgt *); diff --git a/fcst/ft_scst.c b/fcst/ft_scst.c index fb4e576f1..96e44a724 100644 --- a/fcst/ft_scst.c +++ b/fcst/ft_scst.c @@ -44,7 +44,6 @@ struct scst_tgt_template ft_scst_template = { .on_hw_pending_cmd_timeout = ft_cmd_timeout, .on_free_cmd = ft_cmd_free, .task_mgmt_fn_done = ft_cmd_tm_done, - .detect = ft_tgt_detect, .release = ft_tgt_release, .report_aen = ft_report_aen, .enable_target = ft_tgt_enable, diff --git a/fcst/ft_sess.c b/fcst/ft_sess.c index 81caf8bae..f98973408 100644 --- a/fcst/ft_sess.c +++ b/fcst/ft_sess.c @@ -26,8 +26,6 @@ static void ft_sess_put(struct ft_sess *sess); -static int ft_tport_count; - static ssize_t ft_format_wwn(char *buf, size_t len, u64 wwn) { u8 b[8]; @@ -75,7 +73,6 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport) return NULL; } scst_tgt_set_tgt_priv(tport->tgt, tport); - ft_tport_count++; tport->lport = lport; for (i = 0; i < FT_SESS_HASH_SIZE; i++) @@ -120,7 +117,6 @@ static void ft_tport_delete(struct ft_tport *tport) #else call_rcu(&tport->rcu, ft_tport_rcu_free); #endif - ft_tport_count--; } /* @@ -643,11 +639,6 @@ bool ft_tgt_enabled(struct scst_tgt *tgt) return tport->enabled; } -int ft_tgt_detect(struct scst_tgt_template *tt) -{ - return ft_tport_count; -} - /* * Report AEN (Asynchronous Event Notification) from device to initiator. * See notes in scst.h. diff --git a/ibmvstgt/src/ibmvstgt.c b/ibmvstgt/src/ibmvstgt.c index 1dd4dbc7e..5aa033ddc 100644 --- a/ibmvstgt/src/ibmvstgt.c +++ b/ibmvstgt/src/ibmvstgt.c @@ -116,7 +116,6 @@ struct vio_port { bool enabled; }; -static atomic_t ibmvstgt_device_count; static struct workqueue_struct *vtgtd; static unsigned max_vdma_size = MAX_H_COPY_RDMA; static struct scst_tgt_template ibmvstgt_template; @@ -392,16 +391,6 @@ static bool ibmvstgt_is_target_enabled(struct scst_tgt *scst_tgt) } #endif -/** - * ibmvstgt_detect() - Returns the number of target adapters. - * - * Callback function called by the SCST core. - */ -static int ibmvstgt_detect(struct scst_tgt_template *tp) -{ - return atomic_read(&ibmvstgt_device_count); -} - /** * ibmvstgt_release() - Free the resources associated with an SCST target. * @@ -1225,7 +1214,6 @@ static struct scst_tgt_template ibmvstgt_template = { .enable_target = ibmvstgt_enable_target, .is_target_enabled = ibmvstgt_is_target_enabled, #endif - .detect = ibmvstgt_detect, .release = ibmvstgt_release, .xmit_response = ibmvstgt_xmit_response, .rdy_to_xfer = ibmvstgt_rdy_to_xfer, @@ -1308,8 +1296,6 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id) #endif goto destroy_crq_queue; - atomic_inc(&ibmvstgt_device_count); - return 0; destroy_crq_queue: @@ -1334,8 +1320,6 @@ static int ibmvstgt_remove(struct vio_dev *dev) if (!target) return 0; - atomic_dec(&ibmvstgt_device_count); - vport = target->ldata; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) class_device_unregister(&vport->dev); diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 9119cc319..b880a91a0 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3875,12 +3875,6 @@ out: } #endif -static int iscsi_target_detect(struct scst_tgt_template *templ) -{ - /* Nothing to do */ - return 0; -} - static int iscsi_target_release(struct scst_tgt *scst_tgt) { /* Nothing to do */ @@ -3935,7 +3929,6 @@ struct scst_tgt_template iscsi_template = { .trace_tbl_help = ISCSI_TRACE_TBL_HELP, #endif #endif - .detect = iscsi_target_detect, .release = iscsi_target_release, .xmit_response = iscsi_xmit_response, #if !defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) diff --git a/scst/include/scst.h b/scst/include/scst.h index 4401a0b23..d239aa5d3 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1043,7 +1043,7 @@ struct scst_tgt_template { * A negative value should be returned whenever there is * an error. * - * MUST HAVE + * OBSOLETE */ int (*detect)(struct scst_tgt_template *tgt_template); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 6c40d22ea..c39e6f935 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -231,12 +231,9 @@ int __scst_register_target_template(struct scst_tgt_template *vtt, goto out; } - if (!vtt->detect) { - PRINT_ERROR("Target driver %s must have " - "detect() method.", vtt->name); - res = -EINVAL; - goto out; - } + if (vtt->detect) + PRINT_WARNING("detect() method is obsolete and scheduled for " + "removal (target driver %s)", vtt->name); if (!vtt->release) { PRINT_ERROR("Target driver %s must have " @@ -316,7 +313,7 @@ int __scst_register_target_template(struct scst_tgt_template *vtt, mutex_unlock(&scst_mutex); TRACE_DBG("%s", "Calling target driver's detect()"); - res = vtt->detect(vtt); + res = vtt->detect ? vtt->detect(vtt) : 0; TRACE_DBG("Target driver's detect() returned %d", res); if (res < 0) { PRINT_ERROR("%s", "The detect() routine failed"); diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 8f3e182f8..28d3afa34 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1370,14 +1370,6 @@ out: return res; } -static int scst_local_targ_detect(struct scst_tgt_template *tgt_template) -{ - TRACE_ENTRY(); - - TRACE_EXIT(); - return 0; -}; - static int scst_local_targ_release(struct scst_tgt *tgt) { TRACE_ENTRY(); @@ -1574,7 +1566,6 @@ static struct scst_tgt_template scst_local_targ_tmpl = { .mgmt_cmd_help = " echo \"add_session target_name session_name\" >mgmt\n" " echo \"del_session target_name session_name\" >mgmt\n", #endif - .detect = scst_local_targ_detect, .release = scst_local_targ_release, .close_session = scst_local_close_session, .pre_exec = scst_local_targ_pre_exec, diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index b036e747b..d9dab6960 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3755,16 +3755,6 @@ static void srpt_refresh_port_work(struct work_struct *work) srpt_refresh_port(sport); } -/** - * srpt_detect() - Returns the number of target adapters. - * - * Callback function called by the SCST core. - */ -static int srpt_detect(struct scst_tgt_template *tp) -{ - return atomic_read(&srpt_device_count); -} - static int srpt_close_session(struct scst_session *sess) { struct srpt_rdma_ch *ch = scst_sess_get_tgt_priv(sess); @@ -4065,7 +4055,6 @@ static struct scst_tgt_template srpt_template = { .tgt_attrs = srpt_tgt_attrs, .sess_attrs = srpt_sess_attrs, #endif - .detect = srpt_detect, .release = srpt_release, .close_session = srpt_close_session, .xmit_response = srpt_xmit_response,