Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/core: trivial prink cleanup.

1. Replaced printk with appropriate pr_warn, pr_err, pr_info.
2. Removed unnecessary prints around memory allocation failure
which are not required, as reported by the checkpatch script.

Signed-off-by: Parav Pandit <pandit.parav@gmail.com>
Reviewed-by: Haggai Eran <haggaie@mellanox.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Parav Pandit and committed by
Doug Ledford
aba25a3e db9314cd

+77 -89
+7 -8
drivers/infiniband/core/cache.c
··· 1043 1043 1044 1044 ret = ib_query_port(device, port, tprops); 1045 1045 if (ret) { 1046 - printk(KERN_WARNING "ib_query_port failed (%d) for %s\n", 1047 - ret, device->name); 1046 + pr_warn("ib_query_port failed (%d) for %s\n", 1047 + ret, device->name); 1048 1048 goto err; 1049 1049 } 1050 1050 ··· 1067 1067 for (i = 0; i < pkey_cache->table_len; ++i) { 1068 1068 ret = ib_query_pkey(device, port, i, pkey_cache->table + i); 1069 1069 if (ret) { 1070 - printk(KERN_WARNING "ib_query_pkey failed (%d) for %s (index %d)\n", 1071 - ret, device->name, i); 1070 + pr_warn("ib_query_pkey failed (%d) for %s (index %d)\n", 1071 + ret, device->name, i); 1072 1072 goto err; 1073 1073 } 1074 1074 } ··· 1078 1078 ret = ib_query_gid(device, port, i, 1079 1079 gid_cache->table + i, NULL); 1080 1080 if (ret) { 1081 - printk(KERN_WARNING "ib_query_gid failed (%d) for %s (index %d)\n", 1082 - ret, device->name, i); 1081 + pr_warn("ib_query_gid failed (%d) for %s (index %d)\n", 1082 + ret, device->name, i); 1083 1083 goto err; 1084 1084 } 1085 1085 } ··· 1161 1161 GFP_KERNEL); 1162 1162 if (!device->cache.pkey_cache || 1163 1163 !device->cache.lmc_cache) { 1164 - printk(KERN_WARNING "Couldn't allocate cache " 1165 - "for %s\n", device->name); 1164 + pr_warn("Couldn't allocate cache for %s\n", device->name); 1166 1165 return -ENOMEM; 1167 1166 } 1168 1167
+7 -7
drivers/infiniband/core/cma.c
··· 1713 1713 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; 1714 1714 break; 1715 1715 default: 1716 - printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n", 1716 + pr_err("RDMA CMA: unexpected IB CM event: %d\n", 1717 1717 ib_event->event); 1718 1718 goto out; 1719 1719 } ··· 2186 2186 2187 2187 ret = rdma_listen(id, id_priv->backlog); 2188 2188 if (ret) 2189 - printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, " 2190 - "listening on device %s\n", ret, cma_dev->device->name); 2189 + pr_warn("RDMA CMA: cma_listen_on_dev, error %d, listening on device %s\n", 2190 + ret, cma_dev->device->name); 2191 2191 } 2192 2192 2193 2193 static void cma_listen_on_all(struct rdma_id_private *id_priv) ··· 3239 3239 event.status = 0; 3240 3240 break; 3241 3241 default: 3242 - printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n", 3242 + pr_err("RDMA CMA: unexpected IB CM event: %d\n", 3243 3243 ib_event->event); 3244 3244 goto out; 3245 3245 } ··· 4003 4003 if ((dev_addr->bound_dev_if == ndev->ifindex) && 4004 4004 (net_eq(dev_net(ndev), dev_addr->net)) && 4005 4005 memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) { 4006 - printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n", 4007 - ndev->name, &id_priv->id); 4006 + pr_info("RDMA CM addr change for ndev %s used by id %p\n", 4007 + ndev->name, &id_priv->id); 4008 4008 work = kzalloc(sizeof *work, GFP_KERNEL); 4009 4009 if (!work) 4010 4010 return -ENOMEM; ··· 4287 4287 goto err; 4288 4288 4289 4289 if (ibnl_add_client(RDMA_NL_RDMA_CM, RDMA_NL_RDMA_CM_NUM_OPS, cma_cb_table)) 4290 - printk(KERN_WARNING "RDMA CMA: failed to add netlink callback\n"); 4290 + pr_warn("RDMA CMA: failed to add netlink callback\n"); 4291 4291 cma_configfs_init(); 4292 4292 4293 4293 return 0;
+14 -14
drivers/infiniband/core/device.c
··· 115 115 116 116 for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) { 117 117 if (!*(void **) ((void *) device + mandatory_table[i].offset)) { 118 - printk(KERN_WARNING "Device %s is missing mandatory function %s\n", 119 - device->name, mandatory_table[i].name); 118 + pr_warn("Device %s is missing mandatory function %s\n", 119 + device->name, mandatory_table[i].name); 120 120 return -EINVAL; 121 121 } 122 122 } ··· 255 255 256 256 context = kmalloc(sizeof *context, GFP_KERNEL); 257 257 if (!context) { 258 - printk(KERN_WARNING "Couldn't allocate client context for %s/%s\n", 259 - device->name, client->name); 258 + pr_warn("Couldn't allocate client context for %s/%s\n", 259 + device->name, client->name); 260 260 return -ENOMEM; 261 261 } 262 262 ··· 343 343 344 344 ret = read_port_immutable(device); 345 345 if (ret) { 346 - printk(KERN_WARNING "Couldn't create per port immutable data %s\n", 347 - device->name); 346 + pr_warn("Couldn't create per port immutable data %s\n", 347 + device->name); 348 348 goto out; 349 349 } 350 350 351 351 ret = ib_cache_setup_one(device); 352 352 if (ret) { 353 - printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n"); 353 + pr_warn("Couldn't set up InfiniBand P_Key/GID cache\n"); 354 354 goto out; 355 355 } 356 356 357 357 memset(&device->attrs, 0, sizeof(device->attrs)); 358 358 ret = device->query_device(device, &device->attrs, &uhw); 359 359 if (ret) { 360 - printk(KERN_WARNING "Couldn't query the device attributes\n"); 360 + pr_warn("Couldn't query the device attributes\n"); 361 361 ib_cache_cleanup_one(device); 362 362 goto out; 363 363 } 364 364 365 365 ret = ib_device_register_sysfs(device, port_callback); 366 366 if (ret) { 367 - printk(KERN_WARNING "Couldn't register device %s with driver model\n", 368 - device->name); 367 + pr_warn("Couldn't register device %s with driver model\n", 368 + device->name); 369 369 ib_cache_cleanup_one(device); 370 370 goto out; 371 371 } ··· 566 566 goto out; 567 567 } 568 568 569 - printk(KERN_WARNING "No client context found for %s/%s\n", 570 - device->name, client->name); 569 + pr_warn("No client context found for %s/%s\n", 570 + device->name, client->name); 571 571 572 572 out: 573 573 spin_unlock_irqrestore(&device->client_data_lock, flags); ··· 960 960 961 961 ret = class_register(&ib_class); 962 962 if (ret) { 963 - printk(KERN_WARNING "Couldn't create InfiniBand device class\n"); 963 + pr_warn("Couldn't create InfiniBand device class\n"); 964 964 goto err_comp; 965 965 } 966 966 967 967 ret = ibnl_init(); 968 968 if (ret) { 969 - printk(KERN_WARNING "Couldn't init IB netlink interface\n"); 969 + pr_warn("Couldn't init IB netlink interface\n"); 970 970 goto err_sysfs; 971 971 } 972 972
+15 -22
drivers/infiniband/core/fmr_pool.c
··· 150 150 151 151 #ifdef DEBUG 152 152 if (fmr->ref_count !=0) { 153 - printk(KERN_WARNING PFX "Unmapping FMR 0x%08x with ref count %d\n", 154 - fmr, fmr->ref_count); 153 + pr_warn(PFX "Unmapping FMR 0x%08x with ref count %d\n", 154 + fmr, fmr->ref_count); 155 155 } 156 156 #endif 157 157 } ··· 167 167 168 168 ret = ib_unmap_fmr(&fmr_list); 169 169 if (ret) 170 - printk(KERN_WARNING PFX "ib_unmap_fmr returned %d\n", ret); 170 + pr_warn(PFX "ib_unmap_fmr returned %d\n", ret); 171 171 172 172 spin_lock_irq(&pool->pool_lock); 173 173 list_splice(&unmap_list, &pool->free_list); ··· 222 222 device = pd->device; 223 223 if (!device->alloc_fmr || !device->dealloc_fmr || 224 224 !device->map_phys_fmr || !device->unmap_fmr) { 225 - printk(KERN_INFO PFX "Device %s does not support FMRs\n", 226 - device->name); 225 + pr_info(PFX "Device %s does not support FMRs\n", device->name); 227 226 return ERR_PTR(-ENOSYS); 228 227 } 229 228 ··· 232 233 max_remaps = device->attrs.max_map_per_fmr; 233 234 234 235 pool = kmalloc(sizeof *pool, GFP_KERNEL); 235 - if (!pool) { 236 - printk(KERN_WARNING PFX "couldn't allocate pool struct\n"); 236 + if (!pool) 237 237 return ERR_PTR(-ENOMEM); 238 - } 239 238 240 239 pool->cache_bucket = NULL; 241 - 242 240 pool->flush_function = params->flush_function; 243 241 pool->flush_arg = params->flush_arg; 244 242 ··· 247 251 kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket, 248 252 GFP_KERNEL); 249 253 if (!pool->cache_bucket) { 250 - printk(KERN_WARNING PFX "Failed to allocate cache in pool\n"); 254 + pr_warn(PFX "Failed to allocate cache in pool\n"); 251 255 ret = -ENOMEM; 252 256 goto out_free_pool; 253 257 } ··· 271 275 "ib_fmr(%s)", 272 276 device->name); 273 277 if (IS_ERR(pool->thread)) { 274 - printk(KERN_WARNING PFX "couldn't start cleanup thread\n"); 278 + pr_warn(PFX "couldn't start cleanup thread\n"); 275 279 ret = PTR_ERR(pool->thread); 276 280 goto out_free_pool; 277 281 } ··· 290 294 291 295 for (i = 0; i < params->pool_size; ++i) { 292 296 fmr = kmalloc(bytes_per_fmr, GFP_KERNEL); 293 - if (!fmr) { 294 - printk(KERN_WARNING PFX "failed to allocate fmr " 295 - "struct for FMR %d\n", i); 297 + if (!fmr) 296 298 goto out_fail; 297 - } 298 299 299 300 fmr->pool = pool; 300 301 fmr->remap_count = 0; ··· 300 307 301 308 fmr->fmr = ib_alloc_fmr(pd, params->access, &fmr_attr); 302 309 if (IS_ERR(fmr->fmr)) { 303 - printk(KERN_WARNING PFX "fmr_create failed " 304 - "for FMR %d\n", i); 310 + pr_warn(PFX "fmr_create failed for FMR %d\n", 311 + i); 305 312 kfree(fmr); 306 313 goto out_fail; 307 314 } ··· 356 363 } 357 364 358 365 if (i < pool->pool_size) 359 - printk(KERN_WARNING PFX "pool still has %d regions registered\n", 360 - pool->pool_size - i); 366 + pr_warn(PFX "pool still has %d regions registered\n", 367 + pool->pool_size - i); 361 368 362 369 kfree(pool->cache_bucket); 363 370 kfree(pool); ··· 456 463 list_add(&fmr->list, &pool->free_list); 457 464 spin_unlock_irqrestore(&pool->pool_lock, flags); 458 465 459 - printk(KERN_WARNING PFX "fmr_map returns %d\n", result); 466 + pr_warn(PFX "fmr_map returns %d\n", result); 460 467 461 468 return ERR_PTR(result); 462 469 } ··· 510 517 511 518 #ifdef DEBUG 512 519 if (fmr->ref_count < 0) 513 - printk(KERN_WARNING PFX "FMR %p has ref count %d < 0\n", 514 - fmr, fmr->ref_count); 520 + pr_warn(PFX "FMR %p has ref count %d < 0\n", 521 + fmr, fmr->ref_count); 515 522 #endif 516 523 517 524 spin_unlock_irqrestore(&pool->pool_lock, flags);
+6 -8
drivers/infiniband/core/packer.c
··· 44 44 case 4: return be32_to_cpup((__be32 *) (structure + offset)); 45 45 case 8: return be64_to_cpup((__be64 *) (structure + offset)); 46 46 default: 47 - printk(KERN_WARNING "Field size %d bits not handled\n", size * 8); 47 + pr_warn("Field size %d bits not handled\n", size * 8); 48 48 return 0; 49 49 } 50 50 } ··· 104 104 } else { 105 105 if (desc[i].offset_bits % 8 || 106 106 desc[i].size_bits % 8) { 107 - printk(KERN_WARNING "Structure field %s of size %d " 108 - "bits is not byte-aligned\n", 109 - desc[i].field_name, desc[i].size_bits); 107 + pr_warn("Structure field %s of size %d bits is not byte-aligned\n", 108 + desc[i].field_name, desc[i].size_bits); 110 109 } 111 110 112 111 if (desc[i].struct_size_bytes) ··· 131 132 case 32: *(__be32 *) (structure + offset) = cpu_to_be32(val); break; 132 133 case 64: *(__be64 *) (structure + offset) = cpu_to_be64(val); break; 133 134 default: 134 - printk(KERN_WARNING "Field size %d bits not handled\n", size * 8); 135 + pr_warn("Field size %d bits not handled\n", size * 8); 135 136 } 136 137 } 137 138 ··· 187 188 } else { 188 189 if (desc[i].offset_bits % 8 || 189 190 desc[i].size_bits % 8) { 190 - printk(KERN_WARNING "Structure field %s of size %d " 191 - "bits is not byte-aligned\n", 192 - desc[i].field_name, desc[i].size_bits); 191 + pr_warn("Structure field %s of size %d bits is not byte-aligned\n", 192 + desc[i].field_name, desc[i].size_bits); 193 193 } 194 194 195 195 memcpy(structure + desc[i].struct_offset_bytes,
+5 -6
drivers/infiniband/core/sa_query.c
··· 864 864 struct ib_ah_attr ah_attr; 865 865 866 866 if (ib_query_port(port->agent->device, port->port_num, &port_attr)) { 867 - printk(KERN_WARNING "Couldn't query port\n"); 867 + pr_warn("Couldn't query port\n"); 868 868 return; 869 869 } 870 870 871 871 new_ah = kmalloc(sizeof *new_ah, GFP_KERNEL); 872 872 if (!new_ah) { 873 - printk(KERN_WARNING "Couldn't allocate new SM AH\n"); 874 873 return; 875 874 } 876 875 ··· 879 880 new_ah->pkey_index = 0; 880 881 if (ib_find_pkey(port->agent->device, port->port_num, 881 882 IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index)) 882 - printk(KERN_ERR "Couldn't find index for default PKey\n"); 883 + pr_err("Couldn't find index for default PKey\n"); 883 884 884 885 memset(&ah_attr, 0, sizeof ah_attr); 885 886 ah_attr.dlid = port_attr.sm_lid; ··· 888 889 889 890 new_ah->ah = ib_create_ah(port->agent->qp->pd, &ah_attr); 890 891 if (IS_ERR(new_ah->ah)) { 891 - printk(KERN_WARNING "Couldn't create new SM AH\n"); 892 + pr_warn("Couldn't create new SM AH\n"); 892 893 kfree(new_ah); 893 894 return; 894 895 } ··· 1799 1800 1800 1801 ret = ib_register_client(&sa_client); 1801 1802 if (ret) { 1802 - printk(KERN_ERR "Couldn't register ib_sa client\n"); 1803 + pr_err("Couldn't register ib_sa client\n"); 1803 1804 goto err1; 1804 1805 } 1805 1806 1806 1807 ret = mcast_init(); 1807 1808 if (ret) { 1808 - printk(KERN_ERR "Couldn't initialize multicast handling\n"); 1809 + pr_err("Couldn't initialize multicast handling\n"); 1809 1810 goto err2; 1810 1811 } 1811 1812
+4 -4
drivers/infiniband/core/ucm.c
··· 1234 1234 ret = alloc_chrdev_region(&overflow_maj, 0, IB_UCM_MAX_DEVICES, 1235 1235 "infiniband_cm"); 1236 1236 if (ret) { 1237 - printk(KERN_ERR "ucm: couldn't register dynamic device number\n"); 1237 + pr_err("ucm: couldn't register dynamic device number\n"); 1238 1238 return ret; 1239 1239 } 1240 1240 } ··· 1329 1329 ret = register_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES, 1330 1330 "infiniband_cm"); 1331 1331 if (ret) { 1332 - printk(KERN_ERR "ucm: couldn't register device number\n"); 1332 + pr_err("ucm: couldn't register device number\n"); 1333 1333 goto error1; 1334 1334 } 1335 1335 1336 1336 ret = class_create_file(&cm_class, &class_attr_abi_version.attr); 1337 1337 if (ret) { 1338 - printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); 1338 + pr_err("ucm: couldn't create abi_version attribute\n"); 1339 1339 goto error2; 1340 1340 } 1341 1341 1342 1342 ret = ib_register_client(&ucm_client); 1343 1343 if (ret) { 1344 - printk(KERN_ERR "ucm: couldn't register client\n"); 1344 + pr_err("ucm: couldn't register client\n"); 1345 1345 goto error3; 1346 1346 } 1347 1347 return 0;
+3 -3
drivers/infiniband/core/ucma.c
··· 314 314 } 315 315 } 316 316 if (!event_found) 317 - printk(KERN_ERR "ucma_removal_event_handler: warning: connect request event wasn't found\n"); 317 + pr_err("ucma_removal_event_handler: warning: connect request event wasn't found\n"); 318 318 } 319 319 320 320 static int ucma_event_handler(struct rdma_cm_id *cm_id, ··· 1716 1716 1717 1717 ret = device_create_file(ucma_misc.this_device, &dev_attr_abi_version); 1718 1718 if (ret) { 1719 - printk(KERN_ERR "rdma_ucm: couldn't create abi_version attr\n"); 1719 + pr_err("rdma_ucm: couldn't create abi_version attr\n"); 1720 1720 goto err1; 1721 1721 } 1722 1722 1723 1723 ucma_ctl_table_hdr = register_net_sysctl(&init_net, "net/rdma_ucm", ucma_ctl_table); 1724 1724 if (!ucma_ctl_table_hdr) { 1725 - printk(KERN_ERR "rdma_ucm: couldn't register sysctl paths\n"); 1725 + pr_err("rdma_ucm: couldn't register sysctl paths\n"); 1726 1726 ret = -ENOMEM; 1727 1727 goto err2; 1728 1728 }
+11 -12
drivers/infiniband/core/ud_header.c
··· 479 479 buf += IB_LRH_BYTES; 480 480 481 481 if (header->lrh.link_version != 0) { 482 - printk(KERN_WARNING "Invalid LRH.link_version %d\n", 483 - header->lrh.link_version); 482 + pr_warn("Invalid LRH.link_version %d\n", 483 + header->lrh.link_version); 484 484 return -EINVAL; 485 485 } 486 486 ··· 496 496 buf += IB_GRH_BYTES; 497 497 498 498 if (header->grh.ip_version != 6) { 499 - printk(KERN_WARNING "Invalid GRH.ip_version %d\n", 500 - header->grh.ip_version); 499 + pr_warn("Invalid GRH.ip_version %d\n", 500 + header->grh.ip_version); 501 501 return -EINVAL; 502 502 } 503 503 if (header->grh.next_header != 0x1b) { 504 - printk(KERN_WARNING "Invalid GRH.next_header 0x%02x\n", 505 - header->grh.next_header); 504 + pr_warn("Invalid GRH.next_header 0x%02x\n", 505 + header->grh.next_header); 506 506 return -EINVAL; 507 507 } 508 508 break; 509 509 510 510 default: 511 - printk(KERN_WARNING "Invalid LRH.link_next_header %d\n", 512 - header->lrh.link_next_header); 511 + pr_warn("Invalid LRH.link_next_header %d\n", 512 + header->lrh.link_next_header); 513 513 return -EINVAL; 514 514 } 515 515 ··· 525 525 header->immediate_present = 1; 526 526 break; 527 527 default: 528 - printk(KERN_WARNING "Invalid BTH.opcode 0x%02x\n", 529 - header->bth.opcode); 528 + pr_warn("Invalid BTH.opcode 0x%02x\n", header->bth.opcode); 530 529 return -EINVAL; 531 530 } 532 531 533 532 if (header->bth.transport_header_version != 0) { 534 - printk(KERN_WARNING "Invalid BTH.transport_header_version %d\n", 535 - header->bth.transport_header_version); 533 + pr_warn("Invalid BTH.transport_header_version %d\n", 534 + header->bth.transport_header_version); 536 535 return -EINVAL; 537 536 } 538 537
+5 -5
drivers/infiniband/core/uverbs_main.c
··· 1056 1056 ret = alloc_chrdev_region(&overflow_maj, 0, IB_UVERBS_MAX_DEVICES, 1057 1057 "infiniband_verbs"); 1058 1058 if (ret) { 1059 - printk(KERN_ERR "user_verbs: couldn't register dynamic device number\n"); 1059 + pr_err("user_verbs: couldn't register dynamic device number\n"); 1060 1060 return ret; 1061 1061 } 1062 1062 } ··· 1277 1277 ret = register_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES, 1278 1278 "infiniband_verbs"); 1279 1279 if (ret) { 1280 - printk(KERN_ERR "user_verbs: couldn't register device number\n"); 1280 + pr_err("user_verbs: couldn't register device number\n"); 1281 1281 goto out; 1282 1282 } 1283 1283 1284 1284 uverbs_class = class_create(THIS_MODULE, "infiniband_verbs"); 1285 1285 if (IS_ERR(uverbs_class)) { 1286 1286 ret = PTR_ERR(uverbs_class); 1287 - printk(KERN_ERR "user_verbs: couldn't create class infiniband_verbs\n"); 1287 + pr_err("user_verbs: couldn't create class infiniband_verbs\n"); 1288 1288 goto out_chrdev; 1289 1289 } 1290 1290 ··· 1292 1292 1293 1293 ret = class_create_file(uverbs_class, &class_attr_abi_version.attr); 1294 1294 if (ret) { 1295 - printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); 1295 + pr_err("user_verbs: couldn't create abi_version attribute\n"); 1296 1296 goto out_class; 1297 1297 } 1298 1298 1299 1299 ret = ib_register_client(&uverbs_client); 1300 1300 if (ret) { 1301 - printk(KERN_ERR "user_verbs: couldn't register client\n"); 1301 + pr_err("user_verbs: couldn't register client\n"); 1302 1302 goto out_class; 1303 1303 } 1304 1304