Skip to content

Commit aba25a3

Browse files
PanditParavdledford
authored andcommitted
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 <[email protected]> Reviewed-by: Haggai Eran <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent db9314c commit aba25a3

File tree

10 files changed

+77
-89
lines changed

10 files changed

+77
-89
lines changed

drivers/infiniband/core/cache.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ static void ib_cache_update(struct ib_device *device,
10431043

10441044
ret = ib_query_port(device, port, tprops);
10451045
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);
10481048
goto err;
10491049
}
10501050

@@ -1067,8 +1067,8 @@ static void ib_cache_update(struct ib_device *device,
10671067
for (i = 0; i < pkey_cache->table_len; ++i) {
10681068
ret = ib_query_pkey(device, port, i, pkey_cache->table + i);
10691069
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);
10721072
goto err;
10731073
}
10741074
}
@@ -1078,8 +1078,8 @@ static void ib_cache_update(struct ib_device *device,
10781078
ret = ib_query_gid(device, port, i,
10791079
gid_cache->table + i, NULL);
10801080
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);
10831083
goto err;
10841084
}
10851085
}
@@ -1161,8 +1161,7 @@ int ib_cache_setup_one(struct ib_device *device)
11611161
GFP_KERNEL);
11621162
if (!device->cache.pkey_cache ||
11631163
!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);
11661165
return -ENOMEM;
11671166
}
11681167

drivers/infiniband/core/cma.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
17131713
event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
17141714
break;
17151715
default:
1716-
printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
1716+
pr_err("RDMA CMA: unexpected IB CM event: %d\n",
17171717
ib_event->event);
17181718
goto out;
17191719
}
@@ -2186,8 +2186,8 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
21862186

21872187
ret = rdma_listen(id, id_priv->backlog);
21882188
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);
21912191
}
21922192

21932193
static void cma_listen_on_all(struct rdma_id_private *id_priv)
@@ -3239,7 +3239,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
32393239
event.status = 0;
32403240
break;
32413241
default:
3242-
printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
3242+
pr_err("RDMA CMA: unexpected IB CM event: %d\n",
32433243
ib_event->event);
32443244
goto out;
32453245
}
@@ -4003,8 +4003,8 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id
40034003
if ((dev_addr->bound_dev_if == ndev->ifindex) &&
40044004
(net_eq(dev_net(ndev), dev_addr->net)) &&
40054005
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);
40084008
work = kzalloc(sizeof *work, GFP_KERNEL);
40094009
if (!work)
40104010
return -ENOMEM;
@@ -4287,7 +4287,7 @@ static int __init cma_init(void)
42874287
goto err;
42884288

42894289
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");
42914291
cma_configfs_init();
42924292

42934293
return 0;

drivers/infiniband/core/device.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static int ib_device_check_mandatory(struct ib_device *device)
115115

116116
for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
117117
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);
120120
return -EINVAL;
121121
}
122122
}
@@ -255,8 +255,8 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
255255

256256
context = kmalloc(sizeof *context, GFP_KERNEL);
257257
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);
260260
return -ENOMEM;
261261
}
262262

@@ -343,29 +343,29 @@ int ib_register_device(struct ib_device *device,
343343

344344
ret = read_port_immutable(device);
345345
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);
348348
goto out;
349349
}
350350

351351
ret = ib_cache_setup_one(device);
352352
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");
354354
goto out;
355355
}
356356

357357
memset(&device->attrs, 0, sizeof(device->attrs));
358358
ret = device->query_device(device, &device->attrs, &uhw);
359359
if (ret) {
360-
printk(KERN_WARNING "Couldn't query the device attributes\n");
360+
pr_warn("Couldn't query the device attributes\n");
361361
ib_cache_cleanup_one(device);
362362
goto out;
363363
}
364364

365365
ret = ib_device_register_sysfs(device, port_callback);
366366
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);
369369
ib_cache_cleanup_one(device);
370370
goto out;
371371
}
@@ -566,8 +566,8 @@ void ib_set_client_data(struct ib_device *device, struct ib_client *client,
566566
goto out;
567567
}
568568

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);
571571

572572
out:
573573
spin_unlock_irqrestore(&device->client_data_lock, flags);
@@ -960,13 +960,13 @@ static int __init ib_core_init(void)
960960

961961
ret = class_register(&ib_class);
962962
if (ret) {
963-
printk(KERN_WARNING "Couldn't create InfiniBand device class\n");
963+
pr_warn("Couldn't create InfiniBand device class\n");
964964
goto err_comp;
965965
}
966966

967967
ret = ibnl_init();
968968
if (ret) {
969-
printk(KERN_WARNING "Couldn't init IB netlink interface\n");
969+
pr_warn("Couldn't init IB netlink interface\n");
970970
goto err_sysfs;
971971
}
972972

drivers/infiniband/core/fmr_pool.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
150150

151151
#ifdef DEBUG
152152
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);
155155
}
156156
#endif
157157
}
@@ -167,7 +167,7 @@ static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
167167

168168
ret = ib_unmap_fmr(&fmr_list);
169169
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);
171171

172172
spin_lock_irq(&pool->pool_lock);
173173
list_splice(&unmap_list, &pool->free_list);
@@ -222,8 +222,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
222222
device = pd->device;
223223
if (!device->alloc_fmr || !device->dealloc_fmr ||
224224
!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);
227226
return ERR_PTR(-ENOSYS);
228227
}
229228

@@ -233,13 +232,10 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
233232
max_remaps = device->attrs.max_map_per_fmr;
234233

235234
pool = kmalloc(sizeof *pool, GFP_KERNEL);
236-
if (!pool) {
237-
printk(KERN_WARNING PFX "couldn't allocate pool struct\n");
235+
if (!pool)
238236
return ERR_PTR(-ENOMEM);
239-
}
240237

241238
pool->cache_bucket = NULL;
242-
243239
pool->flush_function = params->flush_function;
244240
pool->flush_arg = params->flush_arg;
245241

@@ -251,7 +247,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
251247
kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
252248
GFP_KERNEL);
253249
if (!pool->cache_bucket) {
254-
printk(KERN_WARNING PFX "Failed to allocate cache in pool\n");
250+
pr_warn(PFX "Failed to allocate cache in pool\n");
255251
ret = -ENOMEM;
256252
goto out_free_pool;
257253
}
@@ -275,7 +271,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
275271
"ib_fmr(%s)",
276272
device->name);
277273
if (IS_ERR(pool->thread)) {
278-
printk(KERN_WARNING PFX "couldn't start cleanup thread\n");
274+
pr_warn(PFX "couldn't start cleanup thread\n");
279275
ret = PTR_ERR(pool->thread);
280276
goto out_free_pool;
281277
}
@@ -294,11 +290,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
294290

295291
for (i = 0; i < params->pool_size; ++i) {
296292
fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
297-
if (!fmr) {
298-
printk(KERN_WARNING PFX "failed to allocate fmr "
299-
"struct for FMR %d\n", i);
293+
if (!fmr)
300294
goto out_fail;
301-
}
302295

303296
fmr->pool = pool;
304297
fmr->remap_count = 0;
@@ -307,8 +300,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
307300

308301
fmr->fmr = ib_alloc_fmr(pd, params->access, &fmr_attr);
309302
if (IS_ERR(fmr->fmr)) {
310-
printk(KERN_WARNING PFX "fmr_create failed "
311-
"for FMR %d\n", i);
303+
pr_warn(PFX "fmr_create failed for FMR %d\n",
304+
i);
312305
kfree(fmr);
313306
goto out_fail;
314307
}
@@ -363,8 +356,8 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
363356
}
364357

365358
if (i < pool->pool_size)
366-
printk(KERN_WARNING PFX "pool still has %d regions registered\n",
367-
pool->pool_size - i);
359+
pr_warn(PFX "pool still has %d regions registered\n",
360+
pool->pool_size - i);
368361

369362
kfree(pool->cache_bucket);
370363
kfree(pool);
@@ -463,7 +456,7 @@ struct ib_pool_fmr *ib_fmr_pool_map_phys(struct ib_fmr_pool *pool_handle,
463456
list_add(&fmr->list, &pool->free_list);
464457
spin_unlock_irqrestore(&pool->pool_lock, flags);
465458

466-
printk(KERN_WARNING PFX "fmr_map returns %d\n", result);
459+
pr_warn(PFX "fmr_map returns %d\n", result);
467460

468461
return ERR_PTR(result);
469462
}
@@ -517,8 +510,8 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
517510

518511
#ifdef DEBUG
519512
if (fmr->ref_count < 0)
520-
printk(KERN_WARNING PFX "FMR %p has ref count %d < 0\n",
521-
fmr, fmr->ref_count);
513+
pr_warn(PFX "FMR %p has ref count %d < 0\n",
514+
fmr, fmr->ref_count);
522515
#endif
523516

524517
spin_unlock_irqrestore(&pool->pool_lock, flags);

drivers/infiniband/core/packer.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static u64 value_read(int offset, int size, void *structure)
4444
case 4: return be32_to_cpup((__be32 *) (structure + offset));
4545
case 8: return be64_to_cpup((__be64 *) (structure + offset));
4646
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);
4848
return 0;
4949
}
5050
}
@@ -104,9 +104,8 @@ void ib_pack(const struct ib_field *desc,
104104
} else {
105105
if (desc[i].offset_bits % 8 ||
106106
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);
110109
}
111110

112111
if (desc[i].struct_size_bytes)
@@ -132,7 +131,7 @@ static void value_write(int offset, int size, u64 val, void *structure)
132131
case 32: *(__be32 *) (structure + offset) = cpu_to_be32(val); break;
133132
case 64: *(__be64 *) (structure + offset) = cpu_to_be64(val); break;
134133
default:
135-
printk(KERN_WARNING "Field size %d bits not handled\n", size * 8);
134+
pr_warn("Field size %d bits not handled\n", size * 8);
136135
}
137136
}
138137

@@ -188,9 +187,8 @@ void ib_unpack(const struct ib_field *desc,
188187
} else {
189188
if (desc[i].offset_bits % 8 ||
190189
desc[i].size_bits % 8) {
191-
printk(KERN_WARNING "Structure field %s of size %d "
192-
"bits is not byte-aligned\n",
193-
desc[i].field_name, desc[i].size_bits);
190+
pr_warn("Structure field %s of size %d bits is not byte-aligned\n",
191+
desc[i].field_name, desc[i].size_bits);
194192
}
195193

196194
memcpy(structure + desc[i].struct_offset_bytes,

drivers/infiniband/core/sa_query.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,13 +864,12 @@ static void update_sm_ah(struct work_struct *work)
864864
struct ib_ah_attr ah_attr;
865865

866866
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");
868868
return;
869869
}
870870

871871
new_ah = kmalloc(sizeof *new_ah, GFP_KERNEL);
872872
if (!new_ah) {
873-
printk(KERN_WARNING "Couldn't allocate new SM AH\n");
874873
return;
875874
}
876875

@@ -880,7 +879,7 @@ static void update_sm_ah(struct work_struct *work)
880879
new_ah->pkey_index = 0;
881880
if (ib_find_pkey(port->agent->device, port->port_num,
882881
IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index))
883-
printk(KERN_ERR "Couldn't find index for default PKey\n");
882+
pr_err("Couldn't find index for default PKey\n");
884883

885884
memset(&ah_attr, 0, sizeof ah_attr);
886885
ah_attr.dlid = port_attr.sm_lid;
@@ -889,7 +888,7 @@ static void update_sm_ah(struct work_struct *work)
889888

890889
new_ah->ah = ib_create_ah(port->agent->qp->pd, &ah_attr);
891890
if (IS_ERR(new_ah->ah)) {
892-
printk(KERN_WARNING "Couldn't create new SM AH\n");
891+
pr_warn("Couldn't create new SM AH\n");
893892
kfree(new_ah);
894893
return;
895894
}
@@ -1800,13 +1799,13 @@ static int __init ib_sa_init(void)
18001799

18011800
ret = ib_register_client(&sa_client);
18021801
if (ret) {
1803-
printk(KERN_ERR "Couldn't register ib_sa client\n");
1802+
pr_err("Couldn't register ib_sa client\n");
18041803
goto err1;
18051804
}
18061805

18071806
ret = mcast_init();
18081807
if (ret) {
1809-
printk(KERN_ERR "Couldn't initialize multicast handling\n");
1808+
pr_err("Couldn't initialize multicast handling\n");
18101809
goto err2;
18111810
}
18121811

0 commit comments

Comments
 (0)