Changeset 2791fbb7 in mainline for uspace/drv/block/ata_bd/main.c
- Timestamp:
- 2024-05-16T16:17:49Z (9 months ago)
- Branches:
- master
- Children:
- 59c0f478
- Parents:
- 64cf7a3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ata_bd/main.c
r64cf7a3 r2791fbb7 157 157 } 158 158 159 static char *ata_fun_name( disk_t *disk)159 static char *ata_fun_name(unsigned idx) 160 160 { 161 161 char *fun_name; 162 162 163 if (asprintf(&fun_name, "d%u", disk->disk_id) < 0)163 if (asprintf(&fun_name, "d%u", idx) < 0) 164 164 return NULL; 165 165 … … 167 167 } 168 168 169 errno_t ata_fun_create(disk_t *disk) 170 { 171 ata_ctrl_t *ctrl = disk->ctrl; 169 errno_t ata_fun_create(ata_ctrl_t *ctrl, unsigned idx, void *charg) 170 { 172 171 errno_t rc; 173 172 char *fun_name = NULL; … … 176 175 bool bound = false; 177 176 178 fun_name = ata_fun_name( disk);177 fun_name = ata_fun_name(idx); 179 178 if (fun_name == NULL) { 180 179 ddf_msg(LVL_ERROR, "Out of memory."); … … 199 198 200 199 afun->fun = fun; 201 afun->disk = disk; 202 203 bd_srvs_init(&afun->bds); 204 afun->bds.ops = &ata_bd_ops; 205 afun->bds.sarg = disk; 200 afun->charg = charg; 206 201 207 202 /* Set up a connection handler. */ … … 225 220 226 221 free(fun_name); 227 disk->afun = afun;228 222 return EOK; 229 223 error: … … 238 232 } 239 233 240 errno_t ata_fun_remove( disk_t *disk)234 errno_t ata_fun_remove(ata_ctrl_t *ctrl, unsigned idx) 241 235 { 242 236 errno_t rc; 243 237 char *fun_name; 244 245 if (disk->afun == NULL) 246 return EOK; 247 248 fun_name = ata_fun_name(disk); 238 ata_fun_t *afun = ctrl->fun[idx]; 239 240 fun_name = ata_fun_name(idx); 249 241 if (fun_name == NULL) { 250 242 ddf_msg(LVL_ERROR, "Out of memory."); … … 253 245 } 254 246 255 ddf_msg(LVL_DEBUG, "ata_fun_remove(%p, '%s')", disk, fun_name);256 rc = ddf_fun_offline( disk->afun->fun);247 ddf_msg(LVL_DEBUG, "ata_fun_remove(%p, '%s')", afun, fun_name); 248 rc = ddf_fun_offline(afun->fun); 257 249 if (rc != EOK) { 258 250 ddf_msg(LVL_ERROR, "Error offlining function '%s'.", fun_name); … … 260 252 } 261 253 262 rc = ddf_fun_unbind( disk->afun->fun);254 rc = ddf_fun_unbind(afun->fun); 263 255 if (rc != EOK) { 264 256 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 266 258 } 267 259 268 ddf_fun_destroy(disk->afun->fun); 269 disk->afun = NULL; 260 ddf_fun_destroy(afun->fun); 270 261 free(fun_name); 271 262 return EOK; … … 276 267 } 277 268 278 errno_t ata_fun_unbind( disk_t *disk)269 errno_t ata_fun_unbind(ata_ctrl_t *ctrl, unsigned idx) 279 270 { 280 271 errno_t rc; 281 272 char *fun_name; 282 283 if (disk->afun == NULL) 284 return EOK; 285 286 fun_name = ata_fun_name(disk); 273 ata_fun_t *afun = ctrl->fun[idx]; 274 275 fun_name = ata_fun_name(idx); 287 276 if (fun_name == NULL) { 288 277 ddf_msg(LVL_ERROR, "Out of memory."); … … 291 280 } 292 281 293 ddf_msg(LVL_DEBUG, "ata_fun_unbind(%p, '%s')", disk, fun_name);294 rc = ddf_fun_unbind( disk->afun->fun);282 ddf_msg(LVL_DEBUG, "ata_fun_unbind(%p, '%s')", afun, fun_name); 283 rc = ddf_fun_unbind(afun->fun); 295 284 if (rc != EOK) { 296 285 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 298 287 } 299 288 300 ddf_fun_destroy(disk->afun->fun); 301 disk->afun = NULL; 289 ddf_fun_destroy(afun->fun); 302 290 free(fun_name); 303 291 return EOK; … … 338 326 } 339 327 340 /** Block device connection handler */341 328 static void ata_bd_connection(ipc_call_t *icall, void *arg) 342 329 { … … 344 331 345 332 afun = (ata_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg); 346 bd_conn(icall, &afun->bds);333 ata_connection(icall, afun->charg); 347 334 } 348 335
Note:
See TracChangeset
for help on using the changeset viewer.