@@ -273,14 +273,15 @@ struct bmc_device {
273
273
int dyn_id_set ;
274
274
unsigned long dyn_id_expiry ;
275
275
struct mutex dyn_mutex ; /* protects id & dyn* fields */
276
- unsigned char guid [16 ];
276
+ u8 guid [16 ];
277
277
int guid_set ;
278
278
struct kref usecount ;
279
279
};
280
280
#define to_bmc_device (x ) container_of((x), struct bmc_device, pdev.dev)
281
281
282
282
static int bmc_get_device_id (ipmi_smi_t intf , struct bmc_device * bmc ,
283
- struct ipmi_device_id * id );
283
+ struct ipmi_device_id * id ,
284
+ bool * guid_set , u8 * guid );
284
285
285
286
/*
286
287
* Various statistics for IPMI, these index stats[] in the ipmi_smi
@@ -1220,7 +1221,7 @@ int ipmi_get_version(ipmi_user_t user,
1220
1221
struct ipmi_device_id id ;
1221
1222
int rv ;
1222
1223
1223
- rv = bmc_get_device_id (user -> intf , NULL , & id );
1224
+ rv = bmc_get_device_id (user -> intf , NULL , & id , NULL , NULL );
1224
1225
if (rv )
1225
1226
return rv ;
1226
1227
@@ -2193,7 +2194,8 @@ static int __get_device_id(ipmi_smi_t intf, struct bmc_device *bmc)
2193
2194
* this will always return good data;
2194
2195
*/
2195
2196
static int bmc_get_device_id (ipmi_smi_t intf , struct bmc_device * bmc ,
2196
- struct ipmi_device_id * id )
2197
+ struct ipmi_device_id * id ,
2198
+ bool * guid_set , u8 * guid )
2197
2199
{
2198
2200
int rv = 0 ;
2199
2201
int prev_dyn_id_set ;
@@ -2247,6 +2249,12 @@ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
2247
2249
if (id )
2248
2250
* id = bmc -> id ;
2249
2251
2252
+ if (guid_set )
2253
+ * guid_set = bmc -> guid_set ;
2254
+
2255
+ if (guid && bmc -> guid_set )
2256
+ memcpy (guid , bmc -> guid , 16 );
2257
+
2250
2258
mutex_unlock (& bmc -> dyn_mutex );
2251
2259
mutex_unlock (& intf -> bmc_reg_mutex );
2252
2260
@@ -2286,7 +2294,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v)
2286
2294
struct ipmi_device_id id ;
2287
2295
int rv ;
2288
2296
2289
- rv = bmc_get_device_id (intf , NULL , & id );
2297
+ rv = bmc_get_device_id (intf , NULL , & id , NULL , NULL );
2290
2298
if (rv )
2291
2299
return rv ;
2292
2300
@@ -2478,7 +2486,7 @@ static ssize_t device_id_show(struct device *dev,
2478
2486
struct ipmi_device_id id ;
2479
2487
int rv ;
2480
2488
2481
- rv = bmc_get_device_id (NULL , bmc , & id );
2489
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2482
2490
if (rv )
2483
2491
return rv ;
2484
2492
@@ -2494,7 +2502,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev,
2494
2502
struct ipmi_device_id id ;
2495
2503
int rv ;
2496
2504
2497
- rv = bmc_get_device_id (NULL , bmc , & id );
2505
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2498
2506
if (rv )
2499
2507
return rv ;
2500
2508
@@ -2510,7 +2518,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
2510
2518
struct ipmi_device_id id ;
2511
2519
int rv ;
2512
2520
2513
- rv = bmc_get_device_id (NULL , bmc , & id );
2521
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2514
2522
if (rv )
2515
2523
return rv ;
2516
2524
@@ -2526,7 +2534,7 @@ static ssize_t firmware_revision_show(struct device *dev,
2526
2534
struct ipmi_device_id id ;
2527
2535
int rv ;
2528
2536
2529
- rv = bmc_get_device_id (NULL , bmc , & id );
2537
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2530
2538
if (rv )
2531
2539
return rv ;
2532
2540
@@ -2543,7 +2551,7 @@ static ssize_t ipmi_version_show(struct device *dev,
2543
2551
struct ipmi_device_id id ;
2544
2552
int rv ;
2545
2553
2546
- rv = bmc_get_device_id (NULL , bmc , & id );
2554
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2547
2555
if (rv )
2548
2556
return rv ;
2549
2557
@@ -2561,7 +2569,7 @@ static ssize_t add_dev_support_show(struct device *dev,
2561
2569
struct ipmi_device_id id ;
2562
2570
int rv ;
2563
2571
2564
- rv = bmc_get_device_id (NULL , bmc , & id );
2572
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2565
2573
if (rv )
2566
2574
return rv ;
2567
2575
@@ -2578,7 +2586,7 @@ static ssize_t manufacturer_id_show(struct device *dev,
2578
2586
struct ipmi_device_id id ;
2579
2587
int rv ;
2580
2588
2581
- rv = bmc_get_device_id (NULL , bmc , & id );
2589
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2582
2590
if (rv )
2583
2591
return rv ;
2584
2592
@@ -2594,7 +2602,7 @@ static ssize_t product_id_show(struct device *dev,
2594
2602
struct ipmi_device_id id ;
2595
2603
int rv ;
2596
2604
2597
- rv = bmc_get_device_id (NULL , bmc , & id );
2605
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2598
2606
if (rv )
2599
2607
return rv ;
2600
2608
@@ -2610,7 +2618,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev,
2610
2618
struct ipmi_device_id id ;
2611
2619
int rv ;
2612
2620
2613
- rv = bmc_get_device_id (NULL , bmc , & id );
2621
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2614
2622
if (rv )
2615
2623
return rv ;
2616
2624
@@ -2626,13 +2634,22 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
2626
2634
char * buf )
2627
2635
{
2628
2636
struct bmc_device * bmc = to_bmc_device (dev );
2637
+ bool guid_set ;
2638
+ u8 guid [16 ];
2639
+ int rv ;
2640
+
2641
+ rv = bmc_get_device_id (NULL , bmc , NULL , & guid_set , guid );
2642
+ if (rv )
2643
+ return rv ;
2644
+ if (!guid_set )
2645
+ return - ENOENT ;
2629
2646
2630
2647
return snprintf (buf , 100 ,
2631
- "%2.2x%2.2x%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n" ,
2632
- bmc -> guid [3 ], bmc -> guid [2 ], bmc -> guid [1 ], bmc -> guid [0 ],
2633
- bmc -> guid [5 ], bmc -> guid [4 ], bmc -> guid [7 ], bmc -> guid [6 ],
2634
- bmc -> guid [8 ], bmc -> guid [9 ], bmc -> guid [10 ], bmc -> guid [11 ],
2635
- bmc -> guid [12 ], bmc -> guid [13 ], bmc -> guid [14 ], bmc -> guid [15 ]);
2648
+ "%2.2x%2.2x%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n" ,
2649
+ guid [3 ], guid [2 ], guid [1 ], guid [0 ],
2650
+ guid [5 ], guid [4 ], guid [7 ], guid [6 ],
2651
+ guid [8 ], guid [9 ], guid [10 ], guid [11 ],
2652
+ guid [12 ], guid [13 ], guid [14 ], guid [15 ]);
2636
2653
}
2637
2654
static DEVICE_ATTR (guid , S_IRUGO , guid_show , NULL) ;
2638
2655
@@ -2656,15 +2673,20 @@ static umode_t bmc_dev_attr_is_visible(struct kobject *kobj,
2656
2673
struct device * dev = kobj_to_dev (kobj );
2657
2674
struct bmc_device * bmc = to_bmc_device (dev );
2658
2675
umode_t mode = attr -> mode ;
2659
- struct ipmi_device_id id ;
2660
2676
int rv ;
2661
2677
2662
2678
if (attr == & dev_attr_aux_firmware_revision .attr ) {
2663
- rv = bmc_get_device_id (NULL , bmc , & id );
2679
+ struct ipmi_device_id id ;
2680
+
2681
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2664
2682
return (!rv && id .aux_firmware_revision_set ) ? mode : 0 ;
2665
2683
}
2666
- if (attr == & dev_attr_guid .attr )
2667
- return bmc -> guid_set ? mode : 0 ;
2684
+ if (attr == & dev_attr_guid .attr ) {
2685
+ bool guid_set ;
2686
+
2687
+ rv = bmc_get_device_id (NULL , bmc , NULL , & guid_set , NULL );
2688
+ return (!rv && guid_set ) ? mode : 0 ;
2689
+ }
2668
2690
return mode ;
2669
2691
}
2670
2692
@@ -2685,11 +2707,20 @@ static const struct device_type bmc_device_type = {
2685
2707
static int __find_bmc_guid (struct device * dev , void * data )
2686
2708
{
2687
2709
unsigned char * id = data ;
2710
+ struct bmc_device * bmc ;
2711
+ bool guid_set ;
2712
+ u8 guid [16 ];
2713
+ int rv ;
2688
2714
2689
2715
if (dev -> type != & bmc_device_type )
2690
2716
return 0 ;
2691
2717
2692
- return memcmp (to_bmc_device (dev )-> guid , id , 16 ) == 0 ;
2718
+ bmc = to_bmc_device (dev );
2719
+ rv = bmc_get_device_id (NULL , bmc , NULL , & guid_set , guid );
2720
+ if (rv || !guid_set )
2721
+ return 0 ;
2722
+
2723
+ return memcmp (guid , id , 16 ) == 0 ;
2693
2724
}
2694
2725
2695
2726
/*
@@ -2718,15 +2749,21 @@ struct prod_dev_id {
2718
2749
2719
2750
static int __find_bmc_prod_dev_id (struct device * dev , void * data )
2720
2751
{
2721
- struct prod_dev_id * id = data ;
2752
+ struct prod_dev_id * cid = data ;
2722
2753
struct bmc_device * bmc ;
2754
+ struct ipmi_device_id id ;
2755
+ int rv ;
2723
2756
2724
2757
if (dev -> type != & bmc_device_type )
2725
2758
return 0 ;
2726
2759
2727
2760
bmc = to_bmc_device (dev );
2728
- return (bmc -> id .product_id == id -> product_id
2729
- && bmc -> id .device_id == id -> device_id );
2761
+ rv = bmc_get_device_id (NULL , bmc , & id , NULL , NULL );
2762
+ if (rv )
2763
+ return 0 ;
2764
+
2765
+ return (id .product_id == cid -> product_id
2766
+ && id .device_id == cid -> device_id );
2730
2767
}
2731
2768
2732
2769
/*
@@ -3219,7 +3256,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
3219
3256
3220
3257
get_guid (intf );
3221
3258
3222
- rv = bmc_get_device_id (intf , NULL , & id );
3259
+ rv = bmc_get_device_id (intf , NULL , & id , NULL , NULL );
3223
3260
if (rv ) {
3224
3261
dev_err (si_dev , "Unable to get the device id: %d\n" , rv );
3225
3262
goto out ;
0 commit comments