Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\bsg-lib.c Create Date:2022-07-28 17:38:45
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:sg_setup_queue - Create and add the bsg hooks so we can receive requests*@dev: device to attach bsg device to*@name: device to give bsg device*@job_fn: bsg job handler*@timeout: timeout handler function pointer*@dd_job_size: size of LLD data needed for

Proto:struct request_queue *bsg_setup_queue(struct device *dev, const char *name, bsg_job_fn *job_fn, bsg_timeout_fn *timeout, int dd_job_size)

Type:struct request_queue

Parameter:

TypeParameterName
struct device *dev
const char *name
bsg_job_fn *job_fn
bsg_timeout_fn *timeout
intdd_job_size
368  ret = -ENOMEM
370  bset = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
371  If Not bset Then Return ERR_PTR( - ENOMEM)
374  job_fn = job_fn
375  timeout_fn = timeout
377  set = tag_set
378  ops = bsg_mq_ops , nr_hw_queues = 1
380  queue_depth = 128
381  numa_node = NUMA_NO_NODE
382  cmd_size = sizeof(structbsg_job) + dd_job_size
383  flags = BLK_MQ_F_NO_SCHED | BLK_MQ_F_BLOCKING
384  If Alloc a tag set to be associated with one or more request queues.* May fail with EINVAL for various error conditions. May adjust the* requested depth down, if it's too large. In that case, the set* value will be stored in set->queue_depth. Then Go to out_tag_set
387  q = blk_mq_init_queue(set)
388  If IS_ERR(q) Then
389  ret = PTR_ERR(q)
390  Go to out_queue
393  * The queue owner gets to use this for whatever they like. * ll_rw_blk doesn't touch it. = dev
394  blk_queue_rq_timeout(q, default timeout for SG_IO if none specified)
396  ret = bsg_register_queue(q, dev, name, & bsg_transport_ops)
397  If ret Then
398  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
400  Go to out_cleanup_queue
403  Return q
404  out_cleanup_queue :
405  lk_cleanup_queue - shutdown a request queue*@q: request queue to shutdown* Mark @q DYING, drain all pending requests, mark @q DEAD, destroy and* put it. All future requests will be failed immediately with -ENODEV.
406  out_queue :
407  blk_mq_free_tag_set(set)
408  out_tag_set :
409  kfree(bset)
410  Return ERR_PTR(ret)