@@ -44,10 +44,12 @@ struct ipmi_ipmb_dev {
44
44
45
45
bool ready ;
46
46
47
- u8 bmcaddr ;
48
-
49
47
u8 curr_seq ;
50
48
49
+ u8 bmcaddr ;
50
+ u32 retry_time_ms ;
51
+ u32 max_retries ;
52
+
51
53
struct ipmi_smi_msg * next_msg ;
52
54
struct ipmi_smi_msg * working_msg ;
53
55
@@ -333,7 +335,7 @@ static int ipmi_ipmb_thread(void *data)
333
335
334
336
/* A command was sent, wait for its response. */
335
337
ret = down_timeout (& iidev -> got_rsp ,
336
- msecs_to_jiffies (retry_time_ms ));
338
+ msecs_to_jiffies (iidev -> retry_time_ms ));
337
339
338
340
/*
339
341
* Grab the message if we can. If the handler hasn't
@@ -353,7 +355,7 @@ static int ipmi_ipmb_thread(void *data)
353
355
* the semaphore.
354
356
*/
355
357
down (& iidev -> got_rsp );
356
- } else if (msg && ++ retries <= max_retries ) {
358
+ } else if (msg && ++ retries <= iidev -> max_retries ) {
357
359
spin_lock_irqsave (& iidev -> lock , flags );
358
360
iidev -> working_msg = msg ;
359
361
spin_unlock_irqrestore (& iidev -> lock , flags );
@@ -437,14 +439,30 @@ static int ipmi_ipmb_remove(struct i2c_client *client)
437
439
static int ipmi_ipmb_probe (struct i2c_client * client ,
438
440
const struct i2c_device_id * id )
439
441
{
442
+ struct device * dev = & client -> dev ;
440
443
struct ipmi_ipmb_dev * iidev ;
441
444
int rv ;
442
445
443
446
iidev = devm_kzalloc (& client -> dev , sizeof (* iidev ), GFP_KERNEL );
444
447
if (!iidev )
445
448
return - ENOMEM ;
446
449
447
- iidev -> bmcaddr = bmcaddr ;
450
+ if (of_property_read_u8 (dev -> of_node , "bmcaddr" , & iidev -> bmcaddr ) != 0 )
451
+ iidev -> bmcaddr = bmcaddr ;
452
+ if (iidev -> bmcaddr == 0 || iidev -> bmcaddr & 1 ) {
453
+ /* Can't have the write bit set. */
454
+ dev_notice (& client -> dev ,
455
+ "Invalid bmc address value %2.2x\n" , iidev -> bmcaddr );
456
+ return - EINVAL ;
457
+ }
458
+
459
+ if (of_property_read_u32 (dev -> of_node , "retry-time" ,
460
+ & iidev -> retry_time_ms ) != 0 )
461
+ iidev -> retry_time_ms = retry_time_ms ;
462
+
463
+ if (of_property_read_u32 (dev -> of_node , "max-retries" ,
464
+ & iidev -> max_retries ) != 0 )
465
+ iidev -> max_retries = max_retries ;
448
466
449
467
i2c_set_clientdata (client , iidev );
450
468
client -> flags |= I2C_CLIENT_SLAVE ;
@@ -488,6 +506,16 @@ static int ipmi_ipmb_probe(struct i2c_client *client,
488
506
return rv ;
489
507
}
490
508
509
+ #ifdef CONFIG_OF
510
+ static const struct of_device_id of_ipmi_ipmb_match [] = {
511
+ { .type = "ipmi" , .compatible = DEVICE_NAME },
512
+ {},
513
+ };
514
+ MODULE_DEVICE_TABLE (of , of_ipmi_ipmb_match );
515
+ #else
516
+ #define of_ipmi_ipmb_match NULL
517
+ #endif
518
+
491
519
static const struct i2c_device_id ipmi_ipmb_id [] = {
492
520
{ DEVICE_NAME , 0 },
493
521
{},
@@ -498,6 +526,7 @@ static struct i2c_driver ipmi_ipmb_driver = {
498
526
.class = I2C_CLASS_HWMON ,
499
527
.driver = {
500
528
.name = DEVICE_NAME ,
529
+ .of_match_table = of_ipmi_ipmb_match ,
501
530
},
502
531
.probe = ipmi_ipmb_probe ,
503
532
.remove = ipmi_ipmb_remove ,
0 commit comments