aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2017-09-16 16:51:25 -0400
committerCorey Minyard <cminyard@mvista.com>2017-09-28 13:26:03 -0400
commit55f91cb6f1dfc873359674f35a8ffb1e78429d22 (patch)
treebda2bbbd36d9c053746d1739262ca1c991b8762d
parentac2673d56be609168c3f0792588c1f9ef5824041 (diff)
ipmi: Make the IPMI proc interface configurable
So we can remove it later. Signed-off-by: Corey Minyard <cminyard@mvista.com>
-rw-r--r--drivers/char/ipmi/Kconfig8
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c43
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c4
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c6
-rw-r--r--include/linux/ipmi_smi.h2
5 files changed, 42 insertions, 21 deletions
diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig
index 152ccefdaecb..3544abc0f9f9 100644
--- a/drivers/char/ipmi/Kconfig
+++ b/drivers/char/ipmi/Kconfig
@@ -22,6 +22,14 @@ config IPMI_DMI_DECODE
22 22
23if IPMI_HANDLER 23if IPMI_HANDLER
24 24
25config IPMI_PROC_INTERFACE
26 bool 'Provide an interface for IPMI stats in /proc (deprecated)'
27 depends on PROC_FS
28 default y
29 help
30 Do not use this any more, use sysfs for this info. It will be
31 removed in future kernel versions.
32
25config IPMI_PANIC_EVENT 33config IPMI_PANIC_EVENT
26 bool 'Generate a panic event to all BMCs on a panic' 34 bool 'Generate a panic event to all BMCs on a panic'
27 help 35 help
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 1c8bef2e1dc1..fd3ac6b50412 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -132,9 +132,9 @@ module_param_cb(panic_op, &panic_op_ops, NULL, 0600);
132MODULE_PARM_DESC(panic_op, "Sets if the IPMI driver will attempt to store panic information in the event log in the event of a panic. Set to 'none' for no, 'event' for a single event, or 'string' for a generic event and the panic string in IPMI OEM events."); 132MODULE_PARM_DESC(panic_op, "Sets if the IPMI driver will attempt to store panic information in the event log in the event of a panic. Set to 'none' for no, 'event' for a single event, or 'string' for a generic event and the panic string in IPMI OEM events.");
133 133
134 134
135#ifdef CONFIG_PROC_FS 135#ifdef CONFIG_IPMI_PROC_INTERFACE
136static struct proc_dir_entry *proc_ipmi_root; 136static struct proc_dir_entry *proc_ipmi_root;
137#endif /* CONFIG_PROC_FS */ 137#endif /* CONFIG_IPMI_PROC_INTERFACE */
138 138
139/* Remain in auto-maintenance mode for this amount of time (in ms). */ 139/* Remain in auto-maintenance mode for this amount of time (in ms). */
140#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000 140#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
@@ -267,7 +267,7 @@ struct ipmi_my_addrinfo {
267 unsigned char lun; 267 unsigned char lun;
268}; 268};
269 269
270#ifdef CONFIG_PROC_FS 270#ifdef CONFIG_IPMI_PROC_INTERFACE
271struct ipmi_proc_entry { 271struct ipmi_proc_entry {
272 char *name; 272 char *name;
273 struct ipmi_proc_entry *next; 273 struct ipmi_proc_entry *next;
@@ -449,10 +449,13 @@ struct ipmi_smi {
449 const struct ipmi_smi_handlers *handlers; 449 const struct ipmi_smi_handlers *handlers;
450 void *send_info; 450 void *send_info;
451 451
452#ifdef CONFIG_PROC_FS 452#ifdef CONFIG_IPMI_PROC_INTERFACE
453 /* A list of proc entries for this interface. */ 453 /* A list of proc entries for this interface. */
454 struct mutex proc_entry_lock; 454 struct mutex proc_entry_lock;
455 struct ipmi_proc_entry *proc_entries; 455 struct ipmi_proc_entry *proc_entries;
456
457 struct proc_dir_entry *proc_dir;
458 char proc_dir_name[10];
456#endif 459#endif
457 460
458 /* Driver-model device for the system interface. */ 461 /* Driver-model device for the system interface. */
@@ -542,10 +545,6 @@ struct ipmi_smi {
542 struct ipmi_my_addrinfo addrinfo[IPMI_MAX_CHANNELS]; 545 struct ipmi_my_addrinfo addrinfo[IPMI_MAX_CHANNELS];
543 bool channels_ready; 546 bool channels_ready;
544 547
545 /* Proc FS stuff. */
546 struct proc_dir_entry *proc_dir;
547 char proc_dir_name[10];
548
549 atomic_t stats[IPMI_NUM_STATS]; 548 atomic_t stats[IPMI_NUM_STATS];
550 549
551 /* 550 /*
@@ -2363,7 +2362,7 @@ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
2363 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); 2362 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
2364} 2363}
2365 2364
2366#ifdef CONFIG_PROC_FS 2365#ifdef CONFIG_IPMI_PROC_INTERFACE
2367static int smi_ipmb_proc_show(struct seq_file *m, void *v) 2366static int smi_ipmb_proc_show(struct seq_file *m, void *v)
2368{ 2367{
2369 ipmi_smi_t intf = m->private; 2368 ipmi_smi_t intf = m->private;
@@ -2492,14 +2491,12 @@ static const struct file_operations smi_stats_proc_ops = {
2492 .llseek = seq_lseek, 2491 .llseek = seq_lseek,
2493 .release = single_release, 2492 .release = single_release,
2494}; 2493};
2495#endif /* CONFIG_PROC_FS */
2496 2494
2497int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 2495int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
2498 const struct file_operations *proc_ops, 2496 const struct file_operations *proc_ops,
2499 void *data) 2497 void *data)
2500{ 2498{
2501 int rv = 0; 2499 int rv = 0;
2502#ifdef CONFIG_PROC_FS
2503 struct proc_dir_entry *file; 2500 struct proc_dir_entry *file;
2504 struct ipmi_proc_entry *entry; 2501 struct ipmi_proc_entry *entry;
2505 2502
@@ -2525,7 +2522,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
2525 smi->proc_entries = entry; 2522 smi->proc_entries = entry;
2526 mutex_unlock(&smi->proc_entry_lock); 2523 mutex_unlock(&smi->proc_entry_lock);
2527 } 2524 }
2528#endif /* CONFIG_PROC_FS */
2529 2525
2530 return rv; 2526 return rv;
2531} 2527}
@@ -2535,7 +2531,6 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
2535{ 2531{
2536 int rv = 0; 2532 int rv = 0;
2537 2533
2538#ifdef CONFIG_PROC_FS
2539 sprintf(smi->proc_dir_name, "%d", num); 2534 sprintf(smi->proc_dir_name, "%d", num);
2540 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); 2535 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
2541 if (!smi->proc_dir) 2536 if (!smi->proc_dir)
@@ -2555,14 +2550,12 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
2555 rv = ipmi_smi_add_proc_entry(smi, "version", 2550 rv = ipmi_smi_add_proc_entry(smi, "version",
2556 &smi_version_proc_ops, 2551 &smi_version_proc_ops,
2557 smi); 2552 smi);
2558#endif /* CONFIG_PROC_FS */
2559 2553
2560 return rv; 2554 return rv;
2561} 2555}
2562 2556
2563static void remove_proc_entries(ipmi_smi_t smi) 2557static void remove_proc_entries(ipmi_smi_t smi)
2564{ 2558{
2565#ifdef CONFIG_PROC_FS
2566 struct ipmi_proc_entry *entry; 2559 struct ipmi_proc_entry *entry;
2567 2560
2568 mutex_lock(&smi->proc_entry_lock); 2561 mutex_lock(&smi->proc_entry_lock);
@@ -2576,8 +2569,8 @@ static void remove_proc_entries(ipmi_smi_t smi)
2576 } 2569 }
2577 mutex_unlock(&smi->proc_entry_lock); 2570 mutex_unlock(&smi->proc_entry_lock);
2578 remove_proc_entry(smi->proc_dir_name, proc_ipmi_root); 2571 remove_proc_entry(smi->proc_dir_name, proc_ipmi_root);
2579#endif /* CONFIG_PROC_FS */
2580} 2572}
2573#endif /* CONFIG_IPMI_PROC_INTERFACE */
2581 2574
2582static ssize_t device_id_show(struct device *dev, 2575static ssize_t device_id_show(struct device *dev,
2583 struct device_attribute *attr, 2576 struct device_attribute *attr,
@@ -3419,7 +3412,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
3419 intf->seq_table[j].seqid = 0; 3412 intf->seq_table[j].seqid = 0;
3420 } 3413 }
3421 intf->curr_seq = 0; 3414 intf->curr_seq = 0;
3422#ifdef CONFIG_PROC_FS 3415#ifdef CONFIG_IPMI_PROC_INTERFACE
3423 mutex_init(&intf->proc_entry_lock); 3416 mutex_init(&intf->proc_entry_lock);
3424#endif 3417#endif
3425 spin_lock_init(&intf->waiting_rcv_msgs_lock); 3418 spin_lock_init(&intf->waiting_rcv_msgs_lock);
@@ -3443,7 +3436,9 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
3443 for (i = 0; i < IPMI_NUM_STATS; i++) 3436 for (i = 0; i < IPMI_NUM_STATS; i++)
3444 atomic_set(&intf->stats[i], 0); 3437 atomic_set(&intf->stats[i], 0);
3445 3438
3439#ifdef CONFIG_IPMI_PROC_INTERFACE
3446 intf->proc_dir = NULL; 3440 intf->proc_dir = NULL;
3441#endif
3447 3442
3448 mutex_lock(&smi_watchers_mutex); 3443 mutex_lock(&smi_watchers_mutex);
3449 mutex_lock(&ipmi_interfaces_mutex); 3444 mutex_lock(&ipmi_interfaces_mutex);
@@ -3479,13 +3474,17 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
3479 if (rv) 3474 if (rv)
3480 goto out; 3475 goto out;
3481 3476
3477#ifdef CONFIG_IPMI_PROC_INTERFACE
3482 rv = add_proc_entries(intf, i); 3478 rv = add_proc_entries(intf, i);
3479#endif
3483 3480
3484 out: 3481 out:
3485 if (rv) { 3482 if (rv) {
3486 ipmi_bmc_unregister(intf); 3483 ipmi_bmc_unregister(intf);
3484#ifdef CONFIG_IPMI_PROC_INTERFACE
3487 if (intf->proc_dir) 3485 if (intf->proc_dir)
3488 remove_proc_entries(intf); 3486 remove_proc_entries(intf);
3487#endif
3489 intf->handlers = NULL; 3488 intf->handlers = NULL;
3490 list_del_rcu(&intf->link); 3489 list_del_rcu(&intf->link);
3491 mutex_unlock(&ipmi_interfaces_mutex); 3490 mutex_unlock(&ipmi_interfaces_mutex);
@@ -3590,7 +3589,9 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
3590 intf->handlers = NULL; 3589 intf->handlers = NULL;
3591 mutex_unlock(&ipmi_interfaces_mutex); 3590 mutex_unlock(&ipmi_interfaces_mutex);
3592 3591
3592#ifdef CONFIG_IPMI_PROC_INTERFACE
3593 remove_proc_entries(intf); 3593 remove_proc_entries(intf);
3594#endif
3594 ipmi_bmc_unregister(intf); 3595 ipmi_bmc_unregister(intf);
3595 3596
3596 /* 3597 /*
@@ -5170,7 +5171,7 @@ static int ipmi_init_msghandler(void)
5170 printk(KERN_INFO "ipmi message handler version " 5171 printk(KERN_INFO "ipmi message handler version "
5171 IPMI_DRIVER_VERSION "\n"); 5172 IPMI_DRIVER_VERSION "\n");
5172 5173
5173#ifdef CONFIG_PROC_FS 5174#ifdef CONFIG_IPMI_PROC_INTERFACE
5174 proc_ipmi_root = proc_mkdir("ipmi", NULL); 5175 proc_ipmi_root = proc_mkdir("ipmi", NULL);
5175 if (!proc_ipmi_root) { 5176 if (!proc_ipmi_root) {
5176 printk(KERN_ERR PFX "Unable to create IPMI proc dir"); 5177 printk(KERN_ERR PFX "Unable to create IPMI proc dir");
@@ -5178,7 +5179,7 @@ static int ipmi_init_msghandler(void)
5178 return -ENOMEM; 5179 return -ENOMEM;
5179 } 5180 }
5180 5181
5181#endif /* CONFIG_PROC_FS */ 5182#endif /* CONFIG_IPMI_PROC_INTERFACE */
5182 5183
5183 setup_timer(&ipmi_timer, ipmi_timeout, 0); 5184 setup_timer(&ipmi_timer, ipmi_timeout, 0);
5184 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES); 5185 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
@@ -5218,9 +5219,9 @@ static void __exit cleanup_ipmi(void)
5218 atomic_inc(&stop_operation); 5219 atomic_inc(&stop_operation);
5219 del_timer_sync(&ipmi_timer); 5220 del_timer_sync(&ipmi_timer);
5220 5221
5221#ifdef CONFIG_PROC_FS 5222#ifdef CONFIG_IPMI_PROC_INTERFACE
5222 proc_remove(proc_ipmi_root); 5223 proc_remove(proc_ipmi_root);
5223#endif /* CONFIG_PROC_FS */ 5224#endif /* CONFIG_IPMI_PROC_INTERFACE */
5224 5225
5225 driver_unregister(&ipmidriver.driver); 5226 driver_unregister(&ipmidriver.driver);
5226 5227
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 6ce5b7c8cf93..efc8ee9b5071 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1605,6 +1605,7 @@ out:
1605 return rv; 1605 return rv;
1606} 1606}
1607 1607
1608#ifdef CONFIG_IPMI_PROC_INTERFACE
1608static int smi_type_proc_show(struct seq_file *m, void *v) 1609static int smi_type_proc_show(struct seq_file *m, void *v)
1609{ 1610{
1610 struct smi_info *smi = m->private; 1611 struct smi_info *smi = m->private;
@@ -1698,6 +1699,7 @@ static const struct file_operations smi_params_proc_ops = {
1698 .llseek = seq_lseek, 1699 .llseek = seq_lseek,
1699 .release = single_release, 1700 .release = single_release,
1700}; 1701};
1702#endif
1701 1703
1702#define IPMI_SI_ATTR(name) \ 1704#define IPMI_SI_ATTR(name) \
1703static ssize_t ipmi_##name##_show(struct device *dev, \ 1705static ssize_t ipmi_##name##_show(struct device *dev, \
@@ -2191,6 +2193,7 @@ static int try_smi_init(struct smi_info *new_smi)
2191 goto out_err_remove_attrs; 2193 goto out_err_remove_attrs;
2192 } 2194 }
2193 2195
2196#ifdef CONFIG_IPMI_PROC_INTERFACE
2194 rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", 2197 rv = ipmi_smi_add_proc_entry(new_smi->intf, "type",
2195 &smi_type_proc_ops, 2198 &smi_type_proc_ops,
2196 new_smi); 2199 new_smi);
@@ -2217,6 +2220,7 @@ static int try_smi_init(struct smi_info *new_smi)
2217 "Unable to create proc entry: %d\n", rv); 2220 "Unable to create proc entry: %d\n", rv);
2218 goto out_err_stop_timer; 2221 goto out_err_stop_timer;
2219 } 2222 }
2223#endif
2220 2224
2221 /* Don't increment till we know we have succeeded. */ 2225 /* Don't increment till we know we have succeeded. */
2222 smi_num++; 2226 smi_num++;
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 7b2d4000b11e..aadec879d052 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1344,6 +1344,7 @@ static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
1344 return rv; 1344 return rv;
1345} 1345}
1346 1346
1347#ifdef CONFIG_IPMI_PROC_INTERFACE
1347static int smi_type_proc_show(struct seq_file *m, void *v) 1348static int smi_type_proc_show(struct seq_file *m, void *v)
1348{ 1349{
1349 seq_puts(m, "ssif\n"); 1350 seq_puts(m, "ssif\n");
@@ -1407,6 +1408,7 @@ static const struct file_operations smi_stats_proc_ops = {
1407 .llseek = seq_lseek, 1408 .llseek = seq_lseek,
1408 .release = single_release, 1409 .release = single_release,
1409}; 1410};
1411#endif
1410 1412
1411static int strcmp_nospace(char *s1, char *s2) 1413static int strcmp_nospace(char *s1, char *s2)
1412{ 1414{
@@ -1742,6 +1744,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
1742 goto out_remove_attr; 1744 goto out_remove_attr;
1743 } 1745 }
1744 1746
1747#ifdef CONFIG_IPMI_PROC_INTERFACE
1745 rv = ipmi_smi_add_proc_entry(ssif_info->intf, "type", 1748 rv = ipmi_smi_add_proc_entry(ssif_info->intf, "type",
1746 &smi_type_proc_ops, 1749 &smi_type_proc_ops,
1747 ssif_info); 1750 ssif_info);
@@ -1757,6 +1760,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
1757 pr_err(PFX "Unable to create proc entry: %d\n", rv); 1760 pr_err(PFX "Unable to create proc entry: %d\n", rv);
1758 goto out_err_unreg; 1761 goto out_err_unreg;
1759 } 1762 }
1763#endif
1760 1764
1761 out: 1765 out:
1762 if (rv) { 1766 if (rv) {
@@ -1775,8 +1779,10 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
1775 kfree(resp); 1779 kfree(resp);
1776 return rv; 1780 return rv;
1777 1781
1782#ifdef CONFIG_IPMI_PROC_INTERFACE
1778out_err_unreg: 1783out_err_unreg:
1779 ipmi_unregister_smi(ssif_info->intf); 1784 ipmi_unregister_smi(ssif_info->intf);
1785#endif
1780 1786
1781out_remove_attr: 1787out_remove_attr:
1782 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); 1788 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group);
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 97771e36b7f0..5be51281e14d 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -241,11 +241,13 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
241 msg->done(msg); 241 msg->done(msg);
242} 242}
243 243
244#ifdef CONFIG_IPMI_PROC_INTERFACE
244/* Allow the lower layer to add things to the proc filesystem 245/* Allow the lower layer to add things to the proc filesystem
245 directory for this interface. Note that the entry will 246 directory for this interface. Note that the entry will
246 automatically be dstroyed when the interface is destroyed. */ 247 automatically be dstroyed when the interface is destroyed. */
247int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 248int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
248 const struct file_operations *proc_ops, 249 const struct file_operations *proc_ops,
249 void *data); 250 void *data);
251#endif
250 252
251#endif /* __LINUX_IPMI_SMI_H */ 253#endif /* __LINUX_IPMI_SMI_H */