diff options
-rw-r--r-- | block/blk-integrity.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 61a8e2f8fdd0..91fa8e06b6a5 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -309,24 +309,24 @@ static struct kobj_type integrity_ktype = { | |||
309 | /** | 309 | /** |
310 | * blk_integrity_register - Register a gendisk as being integrity-capable | 310 | * blk_integrity_register - Register a gendisk as being integrity-capable |
311 | * @disk: struct gendisk pointer to make integrity-aware | 311 | * @disk: struct gendisk pointer to make integrity-aware |
312 | * @template: integrity profile | 312 | * @template: optional integrity profile to register |
313 | * | 313 | * |
314 | * Description: When a device needs to advertise itself as being able | 314 | * Description: When a device needs to advertise itself as being able |
315 | * to send/receive integrity metadata it must use this function to | 315 | * to send/receive integrity metadata it must use this function to |
316 | * register the capability with the block layer. The template is a | 316 | * register the capability with the block layer. The template is a |
317 | * blk_integrity struct with values appropriate for the underlying | 317 | * blk_integrity struct with values appropriate for the underlying |
318 | * hardware. See Documentation/block/data-integrity.txt. | 318 | * hardware. If template is NULL the new profile is allocated but |
319 | * not filled out. See Documentation/block/data-integrity.txt. | ||
319 | */ | 320 | */ |
320 | int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) | 321 | int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) |
321 | { | 322 | { |
322 | struct blk_integrity *bi; | 323 | struct blk_integrity *bi; |
323 | 324 | ||
324 | BUG_ON(disk == NULL); | 325 | BUG_ON(disk == NULL); |
325 | BUG_ON(template == NULL); | ||
326 | 326 | ||
327 | if (disk->integrity == NULL) { | 327 | if (disk->integrity == NULL) { |
328 | bi = kmem_cache_alloc(integrity_cachep, | 328 | bi = kmem_cache_alloc(integrity_cachep, |
329 | GFP_KERNEL | __GFP_ZERO); | 329 | GFP_KERNEL | __GFP_ZERO); |
330 | if (!bi) | 330 | if (!bi) |
331 | return -1; | 331 | return -1; |
332 | 332 | ||
@@ -346,13 +346,16 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) | |||
346 | bi = disk->integrity; | 346 | bi = disk->integrity; |
347 | 347 | ||
348 | /* Use the provided profile as template */ | 348 | /* Use the provided profile as template */ |
349 | bi->name = template->name; | 349 | if (template != NULL) { |
350 | bi->generate_fn = template->generate_fn; | 350 | bi->name = template->name; |
351 | bi->verify_fn = template->verify_fn; | 351 | bi->generate_fn = template->generate_fn; |
352 | bi->tuple_size = template->tuple_size; | 352 | bi->verify_fn = template->verify_fn; |
353 | bi->set_tag_fn = template->set_tag_fn; | 353 | bi->tuple_size = template->tuple_size; |
354 | bi->get_tag_fn = template->get_tag_fn; | 354 | bi->set_tag_fn = template->set_tag_fn; |
355 | bi->tag_size = template->tag_size; | 355 | bi->get_tag_fn = template->get_tag_fn; |
356 | bi->tag_size = template->tag_size; | ||
357 | } else | ||
358 | bi->name = "unsupported"; | ||
356 | 359 | ||
357 | return 0; | 360 | return 0; |
358 | } | 361 | } |