aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/device_handler/scsi_dh.c33
-rw-r--r--include/scsi/scsi_device.h1
-rw-r--r--include/scsi/scsi_dh.h5
3 files changed, 39 insertions, 0 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index 53a7385e1b4d..3ee1cbc89479 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -452,6 +452,39 @@ int scsi_dh_activate(struct request_queue *q)
452EXPORT_SYMBOL_GPL(scsi_dh_activate); 452EXPORT_SYMBOL_GPL(scsi_dh_activate);
453 453
454/* 454/*
455 * scsi_dh_set_params - set the parameters for the device as per the
456 * string specified in params.
457 * @q - Request queue that is associated with the scsi_device for
458 * which the parameters to be set.
459 * @params - parameters in the following format
460 * "no_of_params\0param1\0param2\0param3\0...\0"
461 * for example, string for 2 parameters with value 10 and 21
462 * is specified as "2\010\021\0".
463 */
464int scsi_dh_set_params(struct request_queue *q, const char *params)
465{
466 int err = -SCSI_DH_NOSYS;
467 unsigned long flags;
468 struct scsi_device *sdev;
469 struct scsi_device_handler *scsi_dh = NULL;
470
471 spin_lock_irqsave(q->queue_lock, flags);
472 sdev = q->queuedata;
473 if (sdev && sdev->scsi_dh_data)
474 scsi_dh = sdev->scsi_dh_data->scsi_dh;
475 if (scsi_dh && scsi_dh->set_params && get_device(&sdev->sdev_gendev))
476 err = 0;
477 spin_unlock_irqrestore(q->queue_lock, flags);
478
479 if (err)
480 return err;
481 err = scsi_dh->set_params(sdev, params);
482 put_device(&sdev->sdev_gendev);
483 return err;
484}
485EXPORT_SYMBOL_GPL(scsi_dh_set_params);
486
487/*
455 * scsi_dh_handler_exist - Return TRUE(1) if a device handler exists for 488 * scsi_dh_handler_exist - Return TRUE(1) if a device handler exists for
456 * the given name. FALSE(0) otherwise. 489 * the given name. FALSE(0) otherwise.
457 * @name - name of the device handler. 490 * @name - name of the device handler.
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 1f3a4c8044c0..9af48cbf0036 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -187,6 +187,7 @@ struct scsi_device_handler {
187 void (*detach)(struct scsi_device *); 187 void (*detach)(struct scsi_device *);
188 int (*activate)(struct scsi_device *); 188 int (*activate)(struct scsi_device *);
189 int (*prep_fn)(struct scsi_device *, struct request *); 189 int (*prep_fn)(struct scsi_device *, struct request *);
190 int (*set_params)(struct scsi_device *, const char *);
190}; 191};
191 192
192struct scsi_dh_data { 193struct scsi_dh_data {
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h
index 33efce20c26c..ff2407405b42 100644
--- a/include/scsi/scsi_dh.h
+++ b/include/scsi/scsi_dh.h
@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct request_queue *);
60extern int scsi_dh_handler_exist(const char *); 60extern int scsi_dh_handler_exist(const char *);
61extern int scsi_dh_attach(struct request_queue *, const char *); 61extern int scsi_dh_attach(struct request_queue *, const char *);
62extern void scsi_dh_detach(struct request_queue *); 62extern void scsi_dh_detach(struct request_queue *);
63extern int scsi_dh_set_params(struct request_queue *, const char *);
63#else 64#else
64static inline int scsi_dh_activate(struct request_queue *req) 65static inline int scsi_dh_activate(struct request_queue *req)
65{ 66{
@@ -77,4 +78,8 @@ static inline void scsi_dh_detach(struct request_queue *q)
77{ 78{
78 return; 79 return;
79} 80}
81static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
82{
83 return -SCSI_DH_NOSYS;
84}
80#endif 85#endif