@@ -386,7 +386,7 @@ typec_register_altmode(struct device *parent,
386
386
387
387
alt = kzalloc (sizeof (* alt ), GFP_KERNEL );
388
388
if (!alt )
389
- return NULL ;
389
+ return ERR_PTR ( - ENOMEM ) ;
390
390
391
391
alt -> svid = desc -> svid ;
392
392
alt -> n_modes = desc -> n_modes ;
@@ -402,7 +402,7 @@ typec_register_altmode(struct device *parent,
402
402
dev_err (parent , "failed to register alternate mode (%d)\n" ,
403
403
ret );
404
404
put_device (& alt -> dev );
405
- return NULL ;
405
+ return ERR_PTR ( ret ) ;
406
406
}
407
407
408
408
return alt ;
@@ -417,7 +417,7 @@ typec_register_altmode(struct device *parent,
417
417
*/
418
418
void typec_unregister_altmode (struct typec_altmode * alt )
419
419
{
420
- if (alt )
420
+ if (! IS_ERR_OR_NULL ( alt ) )
421
421
device_unregister (& alt -> dev );
422
422
}
423
423
EXPORT_SYMBOL_GPL (typec_unregister_altmode );
@@ -509,7 +509,7 @@ EXPORT_SYMBOL_GPL(typec_partner_register_altmode);
509
509
*
510
510
* Registers a device for USB Type-C Partner described in @desc.
511
511
*
512
- * Returns handle to the partner on success or NULL on failure.
512
+ * Returns handle to the partner on success or ERR_PTR on failure.
513
513
*/
514
514
struct typec_partner * typec_register_partner (struct typec_port * port ,
515
515
struct typec_partner_desc * desc )
@@ -519,7 +519,7 @@ struct typec_partner *typec_register_partner(struct typec_port *port,
519
519
520
520
partner = kzalloc (sizeof (* partner ), GFP_KERNEL );
521
521
if (!partner )
522
- return NULL ;
522
+ return ERR_PTR ( - ENOMEM ) ;
523
523
524
524
partner -> usb_pd = desc -> usb_pd ;
525
525
partner -> accessory = desc -> accessory ;
@@ -542,7 +542,7 @@ struct typec_partner *typec_register_partner(struct typec_port *port,
542
542
if (ret ) {
543
543
dev_err (& port -> dev , "failed to register partner (%d)\n" , ret );
544
544
put_device (& partner -> dev );
545
- return NULL ;
545
+ return ERR_PTR ( ret ) ;
546
546
}
547
547
548
548
return partner ;
@@ -557,7 +557,7 @@ EXPORT_SYMBOL_GPL(typec_register_partner);
557
557
*/
558
558
void typec_unregister_partner (struct typec_partner * partner )
559
559
{
560
- if (partner )
560
+ if (! IS_ERR_OR_NULL ( partner ) )
561
561
device_unregister (& partner -> dev );
562
562
}
563
563
EXPORT_SYMBOL_GPL (typec_unregister_partner );
@@ -587,7 +587,7 @@ static const struct device_type typec_plug_dev_type = {
587
587
* the plug lists in response to Discover Modes command need to be listed in an
588
588
* array in @desc.
589
589
*
590
- * Returns handle to the alternate mode on success or NULL on failure.
590
+ * Returns handle to the alternate mode on success or ERR_PTR on failure.
591
591
*/
592
592
struct typec_altmode *
593
593
typec_plug_register_altmode (struct typec_plug * plug ,
@@ -606,7 +606,7 @@ EXPORT_SYMBOL_GPL(typec_plug_register_altmode);
606
606
* Cable Plug represents a plug with electronics in it that can response to USB
607
607
* Power Delivery SOP Prime or SOP Double Prime packages.
608
608
*
609
- * Returns handle to the cable plug on success or NULL on failure.
609
+ * Returns handle to the cable plug on success or ERR_PTR on failure.
610
610
*/
611
611
struct typec_plug * typec_register_plug (struct typec_cable * cable ,
612
612
struct typec_plug_desc * desc )
@@ -617,7 +617,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
617
617
618
618
plug = kzalloc (sizeof (* plug ), GFP_KERNEL );
619
619
if (!plug )
620
- return NULL ;
620
+ return ERR_PTR ( - ENOMEM ) ;
621
621
622
622
sprintf (name , "plug%d" , desc -> index );
623
623
@@ -631,7 +631,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
631
631
if (ret ) {
632
632
dev_err (& cable -> dev , "failed to register plug (%d)\n" , ret );
633
633
put_device (& plug -> dev );
634
- return NULL ;
634
+ return ERR_PTR ( ret ) ;
635
635
}
636
636
637
637
return plug ;
@@ -646,7 +646,7 @@ EXPORT_SYMBOL_GPL(typec_register_plug);
646
646
*/
647
647
void typec_unregister_plug (struct typec_plug * plug )
648
648
{
649
- if (plug )
649
+ if (! IS_ERR_OR_NULL ( plug ) )
650
650
device_unregister (& plug -> dev );
651
651
}
652
652
EXPORT_SYMBOL_GPL (typec_unregister_plug );
@@ -724,7 +724,7 @@ EXPORT_SYMBOL_GPL(typec_cable_set_identity);
724
724
* Registers a device for USB Type-C Cable described in @desc. The cable will be
725
725
* parent for the optional cable plug devises.
726
726
*
727
- * Returns handle to the cable on success or NULL on failure.
727
+ * Returns handle to the cable on success or ERR_PTR on failure.
728
728
*/
729
729
struct typec_cable * typec_register_cable (struct typec_port * port ,
730
730
struct typec_cable_desc * desc )
@@ -734,7 +734,7 @@ struct typec_cable *typec_register_cable(struct typec_port *port,
734
734
735
735
cable = kzalloc (sizeof (* cable ), GFP_KERNEL );
736
736
if (!cable )
737
- return NULL ;
737
+ return ERR_PTR ( - ENOMEM ) ;
738
738
739
739
cable -> type = desc -> type ;
740
740
cable -> active = desc -> active ;
@@ -757,7 +757,7 @@ struct typec_cable *typec_register_cable(struct typec_port *port,
757
757
if (ret ) {
758
758
dev_err (& port -> dev , "failed to register cable (%d)\n" , ret );
759
759
put_device (& cable -> dev );
760
- return NULL ;
760
+ return ERR_PTR ( ret ) ;
761
761
}
762
762
763
763
return cable ;
@@ -772,7 +772,7 @@ EXPORT_SYMBOL_GPL(typec_register_cable);
772
772
*/
773
773
void typec_unregister_cable (struct typec_cable * cable )
774
774
{
775
- if (cable )
775
+ if (! IS_ERR_OR_NULL ( cable ) )
776
776
device_unregister (& cable -> dev );
777
777
}
778
778
EXPORT_SYMBOL_GPL (typec_unregister_cable );
@@ -1256,7 +1256,7 @@ EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
1256
1256
* This routine is used to register an alternate mode that @port is capable of
1257
1257
* supporting.
1258
1258
*
1259
- * Returns handle to the alternate mode on success or NULL on failure.
1259
+ * Returns handle to the alternate mode on success or ERR_PTR on failure.
1260
1260
*/
1261
1261
struct typec_altmode *
1262
1262
typec_port_register_altmode (struct typec_port * port ,
@@ -1273,7 +1273,7 @@ EXPORT_SYMBOL_GPL(typec_port_register_altmode);
1273
1273
*
1274
1274
* Registers a device for USB Type-C Port described in @cap.
1275
1275
*
1276
- * Returns handle to the port on success or NULL on failure.
1276
+ * Returns handle to the port on success or ERR_PTR on failure.
1277
1277
*/
1278
1278
struct typec_port * typec_register_port (struct device * parent ,
1279
1279
const struct typec_capability * cap )
@@ -1285,12 +1285,12 @@ struct typec_port *typec_register_port(struct device *parent,
1285
1285
1286
1286
port = kzalloc (sizeof (* port ), GFP_KERNEL );
1287
1287
if (!port )
1288
- return NULL ;
1288
+ return ERR_PTR ( - ENOMEM ) ;
1289
1289
1290
1290
id = ida_simple_get (& typec_index_ida , 0 , 0 , GFP_KERNEL );
1291
1291
if (id < 0 ) {
1292
1292
kfree (port );
1293
- return NULL ;
1293
+ return ERR_PTR ( id ) ;
1294
1294
}
1295
1295
1296
1296
if (cap -> type == TYPEC_PORT_DFP )
@@ -1326,7 +1326,7 @@ struct typec_port *typec_register_port(struct device *parent,
1326
1326
if (ret ) {
1327
1327
dev_err (parent , "failed to register port (%d)\n" , ret );
1328
1328
put_device (& port -> dev );
1329
- return NULL ;
1329
+ return ERR_PTR ( ret ) ;
1330
1330
}
1331
1331
1332
1332
return port ;
@@ -1341,7 +1341,7 @@ EXPORT_SYMBOL_GPL(typec_register_port);
1341
1341
*/
1342
1342
void typec_unregister_port (struct typec_port * port )
1343
1343
{
1344
- if (port )
1344
+ if (! IS_ERR_OR_NULL ( port ) )
1345
1345
device_unregister (& port -> dev );
1346
1346
}
1347
1347
EXPORT_SYMBOL_GPL (typec_unregister_port );
0 commit comments