Changeset 1634
- Timestamp:
- 11/21/02 02:32:35 (11 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/busses/i2c-ipmi.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/busses/i2c-ipmi.c
r1625 r1634 110 110 /************** Message Sending **************/ 111 111 112 static int find_client(struct i2c_client * client) 113 { 114 int i; 115 116 for (i = 0; i < I2C_CLIENT_MAX; i++) 117 if (client == i2c_ipmi_adapter.clients[i]) 118 return i; 119 return -1; 120 } 121 112 122 static void ipmi_i2c_send_message(int id, struct ipmi_msg * msg) 113 123 { 114 ipmi_request(i2c_ipmi_user, &address, id, msg, 0);124 ipmi_request(i2c_ipmi_user, &address, (long) id, msg, 0); 115 125 } 116 126 … … 124 134 struct ipmi_msg *msg = (struct ipmi_msg *) mesg; 125 135 struct i2c_client *client = (struct i2c_client *) clnt; 126 127 /* todo: keep track of multiple clients and save callback for each */ 128 id = (id & 0xffffff) | 0x1000000; 129 rcv_callback = client->driver->command; 136 int clientid; 137 138 #ifdef DEBUG 139 if(msg->data == NULL) 140 printk(KERN_INFO "i2c-ipmi.o: Send 0x%x\n", msg->cmd); 141 else 142 printk(KERN_INFO "i2c-ipmi.o: Send 0x%x 0x%x 0x%x\n", msg->cmd, msg->data[0], msg->data[1]); 143 #endif 144 /* save the client number in the upper 8 bits of the message id */ 145 if((clientid = find_client(client)) < 0) { 146 printk(KERN_WARNING "i2c-ipmi.o: Request from unknown client\n"); 147 return -1; 148 } 149 150 id = (id & 0xffffff) | (clientid << 24); 130 151 ipmi_i2c_send_message(id, msg); 131 152 return 0; … … 138 159 { 139 160 int rcvid = msg->msgid & 0xffffff; 140 int client = (msg->msgid >> 24) & 0xf;161 int clientid = (msg->msgid >> 24) & 0xff; 141 162 142 163 #ifdef DEBUG 143 164 if (msg->msg.data[0] != 0) 144 printk(KERN_WARNING " IPMI BMC response: Error 0x%x on cmd 0x%x/0x%x\n",165 printk(KERN_WARNING "i2c-ipmi.o: Error 0x%x on cmd 0x%x/0x%x\n", 145 166 msg->msg.data[0], msg->msg.netfn, msg->msg.cmd); 146 167 #endif 147 /* todo: keep track of multiple clients */ 148 if(client == 1 && rcv_callback != NULL) 149 (*rcv_callback)(NULL, client, msg); 150 else 168 /* Protect ourselves here; verify the client and its callback 169 since the client may have gone away since 170 the message was sent! */ 171 if(clientid < I2C_CLIENT_MAX && 172 i2c_ipmi_adapter.clients[clientid] != NULL && 173 i2c_ipmi_adapter.clients[clientid]->driver->command != NULL) 174 (* i2c_ipmi_adapter.clients[clientid]->driver->command) 175 (i2c_ipmi_adapter.clients[clientid], rcvid, msg); 176 else { 177 printk(KERN_WARNING "i2c-ipmi.o: Response for unknown client\n"); 151 178 ipmi_free_recv_msg(msg); 179 } 152 180 } 153 181
