@@ -76,20 +76,18 @@ mlx5_devcom_dev_alloc(struct mlx5_core_dev *dev)
7676struct mlx5_devcom_dev *
7777mlx5_devcom_register_device (struct mlx5_core_dev * dev )
7878{
79- struct mlx5_devcom_dev * devc ;
79+ struct mlx5_devcom_dev * devc = NULL ;
8080
8181 mutex_lock (& dev_list_lock );
8282
8383 if (devcom_dev_exists (dev )) {
84- devc = ERR_PTR ( - EEXIST );
84+ mlx5_core_err ( dev , "devcom device already exists" );
8585 goto out ;
8686 }
8787
8888 devc = mlx5_devcom_dev_alloc (dev );
89- if (!devc ) {
90- devc = ERR_PTR (- ENOMEM );
89+ if (!devc )
9190 goto out ;
92- }
9391
9492 list_add_tail (& devc -> list , & devcom_dev_list );
9593out :
@@ -110,8 +108,10 @@ mlx5_devcom_dev_release(struct kref *ref)
110108
111109void mlx5_devcom_unregister_device (struct mlx5_devcom_dev * devc )
112110{
113- if (!IS_ERR_OR_NULL (devc ))
114- kref_put (& devc -> ref , mlx5_devcom_dev_release );
111+ if (!devc )
112+ return ;
113+
114+ kref_put (& devc -> ref , mlx5_devcom_dev_release );
115115}
116116
117117static struct mlx5_devcom_comp *
@@ -122,7 +122,7 @@ mlx5_devcom_comp_alloc(u64 id, const struct mlx5_devcom_match_attr *attr,
122122
123123 comp = kzalloc (sizeof (* comp ), GFP_KERNEL );
124124 if (!comp )
125- return ERR_PTR ( - ENOMEM ) ;
125+ return NULL ;
126126
127127 comp -> id = id ;
128128 comp -> key .key = attr -> key ;
@@ -160,7 +160,7 @@ devcom_alloc_comp_dev(struct mlx5_devcom_dev *devc,
160160
161161 devcom = kzalloc (sizeof (* devcom ), GFP_KERNEL );
162162 if (!devcom )
163- return ERR_PTR ( - ENOMEM ) ;
163+ return NULL ;
164164
165165 kref_get (& devc -> ref );
166166 devcom -> devc = devc ;
@@ -240,31 +240,28 @@ mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
240240 mlx5_devcom_event_handler_t handler ,
241241 void * data )
242242{
243- struct mlx5_devcom_comp_dev * devcom ;
243+ struct mlx5_devcom_comp_dev * devcom = NULL ;
244244 struct mlx5_devcom_comp * comp ;
245245
246- if (IS_ERR_OR_NULL ( devc ) )
247- return ERR_PTR ( - EINVAL ) ;
246+ if (! devc )
247+ return NULL ;
248248
249249 mutex_lock (& comp_list_lock );
250250 comp = devcom_component_get (devc , id , attr , handler );
251- if (IS_ERR (comp )) {
252- devcom = ERR_PTR (- EINVAL );
251+ if (IS_ERR (comp ))
253252 goto out_unlock ;
254- }
255253
256254 if (!comp ) {
257255 comp = mlx5_devcom_comp_alloc (id , attr , handler );
258- if (IS_ERR (comp )) {
259- devcom = ERR_CAST (comp );
256+ if (!comp )
260257 goto out_unlock ;
261- }
258+
262259 list_add_tail (& comp -> comp_list , & devcom_comp_list );
263260 }
264261 mutex_unlock (& comp_list_lock );
265262
266263 devcom = devcom_alloc_comp_dev (devc , comp , data );
267- if (IS_ERR ( devcom ) )
264+ if (! devcom )
268265 kref_put (& comp -> ref , mlx5_devcom_comp_release );
269266
270267 return devcom ;
@@ -276,8 +273,10 @@ mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
276273
277274void mlx5_devcom_unregister_component (struct mlx5_devcom_comp_dev * devcom )
278275{
279- if (!IS_ERR_OR_NULL (devcom ))
280- devcom_free_comp_dev (devcom );
276+ if (!devcom )
277+ return ;
278+
279+ devcom_free_comp_dev (devcom );
281280}
282281
283282int mlx5_devcom_comp_get_size (struct mlx5_devcom_comp_dev * devcom )
@@ -296,7 +295,7 @@ int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
296295 int err = 0 ;
297296 void * data ;
298297
299- if (IS_ERR_OR_NULL ( devcom ) )
298+ if (! devcom )
300299 return - ENODEV ;
301300
302301 comp = devcom -> comp ;
@@ -338,7 +337,7 @@ void mlx5_devcom_comp_set_ready(struct mlx5_devcom_comp_dev *devcom, bool ready)
338337
339338bool mlx5_devcom_comp_is_ready (struct mlx5_devcom_comp_dev * devcom )
340339{
341- if (IS_ERR_OR_NULL ( devcom ) )
340+ if (! devcom )
342341 return false;
343342
344343 return READ_ONCE (devcom -> comp -> ready );
@@ -348,7 +347,7 @@ bool mlx5_devcom_for_each_peer_begin(struct mlx5_devcom_comp_dev *devcom)
348347{
349348 struct mlx5_devcom_comp * comp ;
350349
351- if (IS_ERR_OR_NULL ( devcom ) )
350+ if (! devcom )
352351 return false;
353352
354353 comp = devcom -> comp ;
@@ -421,21 +420,21 @@ void *mlx5_devcom_get_next_peer_data_rcu(struct mlx5_devcom_comp_dev *devcom,
421420
422421void mlx5_devcom_comp_lock (struct mlx5_devcom_comp_dev * devcom )
423422{
424- if (IS_ERR_OR_NULL ( devcom ) )
423+ if (! devcom )
425424 return ;
426425 down_write (& devcom -> comp -> sem );
427426}
428427
429428void mlx5_devcom_comp_unlock (struct mlx5_devcom_comp_dev * devcom )
430429{
431- if (IS_ERR_OR_NULL ( devcom ) )
430+ if (! devcom )
432431 return ;
433432 up_write (& devcom -> comp -> sem );
434433}
435434
436435int mlx5_devcom_comp_trylock (struct mlx5_devcom_comp_dev * devcom )
437436{
438- if (IS_ERR_OR_NULL ( devcom ) )
437+ if (! devcom )
439438 return 0 ;
440439 return down_write_trylock (& devcom -> comp -> sem );
441440}
0 commit comments