Lines Matching refs:block
41 struct w1_cb_block *block; member
55 static u16 w1_reply_len(struct w1_cb_block *block) in w1_reply_len() argument
57 if (!block->cn) in w1_reply_len()
59 return (u8 *)block->cn - (u8 *)block->first_cn + block->cn->len; in w1_reply_len()
62 static void w1_unref_block(struct w1_cb_block *block) in w1_unref_block() argument
64 if (atomic_sub_return(1, &block->refcnt) == 0) { in w1_unref_block()
65 u16 len = w1_reply_len(block); in w1_unref_block()
67 cn_netlink_send_mult(block->first_cn, len, in w1_unref_block()
68 block->portid, 0, in w1_unref_block()
71 kfree(block); in w1_unref_block()
83 static void w1_reply_make_space(struct w1_cb_block *block, u16 space) in w1_reply_make_space() argument
85 u16 len = w1_reply_len(block); in w1_reply_make_space()
86 if (len + space >= block->maxlen) { in w1_reply_make_space()
87 cn_netlink_send_mult(block->first_cn, len, block->portid, in w1_reply_make_space()
89 block->first_cn->len = 0; in w1_reply_make_space()
90 block->cn = NULL; in w1_reply_make_space()
91 block->msg = NULL; in w1_reply_make_space()
92 block->cmd = NULL; in w1_reply_make_space()
97 static void w1_netlink_check_send(struct w1_cb_block *block) in w1_netlink_check_send() argument
99 if (!(block->request_cn.flags & W1_CN_BUNDLE) && block->cn) in w1_netlink_check_send()
100 w1_reply_make_space(block, block->maxlen); in w1_netlink_check_send()
112 static void w1_netlink_setup_msg(struct w1_cb_block *block, u32 ack) in w1_netlink_setup_msg() argument
114 if (block->cn && block->cn->ack == ack) { in w1_netlink_setup_msg()
115 block->msg = (struct w1_netlink_msg *)(block->cn->data + block->cn->len); in w1_netlink_setup_msg()
118 if (block->cn) in w1_netlink_setup_msg()
119 block->cn = (struct cn_msg *)(block->cn->data + in w1_netlink_setup_msg()
120 block->cn->len); in w1_netlink_setup_msg()
122 block->cn = block->first_cn; in w1_netlink_setup_msg()
124 memcpy(block->cn, &block->request_cn, sizeof(*block->cn)); in w1_netlink_setup_msg()
125 block->cn->len = 0; in w1_netlink_setup_msg()
126 block->cn->ack = ack; in w1_netlink_setup_msg()
127 block->msg = (struct w1_netlink_msg *)block->cn->data; in w1_netlink_setup_msg()
135 static void w1_netlink_queue_cmd(struct w1_cb_block *block, in w1_netlink_queue_cmd() argument
139 w1_reply_make_space(block, sizeof(struct cn_msg) + in w1_netlink_queue_cmd()
146 w1_netlink_setup_msg(block, block->request_cn.seq + 1); in w1_netlink_queue_cmd()
147 memcpy(block->msg, block->cur_msg, sizeof(*block->msg)); in w1_netlink_queue_cmd()
148 block->cn->len += sizeof(*block->msg); in w1_netlink_queue_cmd()
149 block->msg->len = 0; in w1_netlink_queue_cmd()
150 block->cmd = (struct w1_netlink_cmd *)(block->msg->data); in w1_netlink_queue_cmd()
153 if (block->cmd != cmd) in w1_netlink_queue_cmd()
154 memcpy(block->cmd, cmd, space); in w1_netlink_queue_cmd()
155 block->cn->len += space; in w1_netlink_queue_cmd()
156 block->msg->len += space; in w1_netlink_queue_cmd()
162 static void w1_netlink_queue_status(struct w1_cb_block *block, in w1_netlink_queue_status() argument
167 w1_reply_make_space(block, space); in w1_netlink_queue_status()
168 w1_netlink_setup_msg(block, block->request_cn.ack); in w1_netlink_queue_status()
170 memcpy(block->msg, req_msg, sizeof(*req_msg)); in w1_netlink_queue_status()
171 block->cn->len += sizeof(*req_msg); in w1_netlink_queue_status()
172 block->msg->len = 0; in w1_netlink_queue_status()
173 block->msg->status = (u8)-error; in w1_netlink_queue_status()
175 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)block->msg->data; in w1_netlink_queue_status()
177 block->cn->len += sizeof(*cmd); in w1_netlink_queue_status()
178 block->msg->len += sizeof(*cmd); in w1_netlink_queue_status()
181 w1_netlink_check_send(block); in w1_netlink_queue_status()
238 struct w1_cb_block *block = dev->priv; in w1_send_slave() local
239 struct w1_netlink_cmd *cache_cmd = block->cmd; in w1_send_slave()
242 w1_reply_make_space(block, sizeof(*data)); in w1_send_slave()
245 if (!block->cmd) { in w1_send_slave()
247 w1_netlink_queue_cmd(block, cache_cmd); in w1_send_slave()
250 data = (u64 *)(block->cmd->data + block->cmd->len); in w1_send_slave()
253 block->cn->len += sizeof(*data); in w1_send_slave()
254 block->msg->len += sizeof(*data); in w1_send_slave()
255 block->cmd->len += sizeof(*data); in w1_send_slave()
455 dev->priv = node->block; in w1_process_cb()
458 node->block->cur_msg = node->msg; in w1_process_cb()
470 w1_netlink_check_send(node->block); in w1_process_cb()
472 w1_netlink_queue_status(node->block, node->msg, cmd, err); in w1_process_cb()
481 w1_netlink_queue_status(node->block, node->msg, cmd, err); in w1_process_cb()
497 w1_unref_block(node->block); in w1_process_cb()
545 struct w1_cb_block *block = NULL; in w1_cn_callback() local
605 block = kzalloc(size, GFP_KERNEL); in w1_cn_callback()
606 if (!block) { in w1_cn_callback()
614 atomic_set(&block->refcnt, 1); in w1_cn_callback()
615 block->portid = nsp->portid; in w1_cn_callback()
616 block->request_cn = *cn; in w1_cn_callback()
617 memcpy(block->request_cn.data, cn->data, cn->len); in w1_cn_callback()
618 node = (struct w1_cb_node *)(block->request_cn.data + cn->len); in w1_cn_callback()
629 block->maxlen = reply_size; in w1_cn_callback()
630 block->first_cn = (struct cn_msg *)(node + node_count); in w1_cn_callback()
631 memset(block->first_cn, 0, sizeof(*block->first_cn)); in w1_cn_callback()
681 atomic_inc(&block->refcnt); in w1_cn_callback()
683 node->block = block; in w1_cn_callback()
684 node->msg = (struct w1_netlink_msg *)((u8 *)&block->request_cn + in w1_cn_callback()
712 if (block) in w1_cn_callback()
713 w1_unref_block(block); in w1_cn_callback()