Skip to content

Commit

Permalink
ipmi: Make the IPMI proc interface configurable
Browse files Browse the repository at this point in the history
So we can remove it later.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
  • Loading branch information
Corey Minyard committed Sep 28, 2017
1 parent ac2673d commit 55f91cb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
8 changes: 8 additions & 0 deletions drivers/char/ipmi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ config IPMI_DMI_DECODE

if IPMI_HANDLER

config IPMI_PROC_INTERFACE
bool 'Provide an interface for IPMI stats in /proc (deprecated)'
depends on PROC_FS
default y
help
Do not use this any more, use sysfs for this info. It will be
removed in future kernel versions.

config IPMI_PANIC_EVENT
bool 'Generate a panic event to all BMCs on a panic'
help
Expand Down
43 changes: 22 additions & 21 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ module_param_cb(panic_op, &panic_op_ops, NULL, 0600);
MODULE_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.");


#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
static struct proc_dir_entry *proc_ipmi_root;
#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_IPMI_PROC_INTERFACE */

/* Remain in auto-maintenance mode for this amount of time (in ms). */
#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
Expand Down Expand Up @@ -267,7 +267,7 @@ struct ipmi_my_addrinfo {
unsigned char lun;
};

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
struct ipmi_proc_entry {
char *name;
struct ipmi_proc_entry *next;
Expand Down Expand Up @@ -449,10 +449,13 @@ struct ipmi_smi {
const struct ipmi_smi_handlers *handlers;
void *send_info;

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
/* A list of proc entries for this interface. */
struct mutex proc_entry_lock;
struct ipmi_proc_entry *proc_entries;

struct proc_dir_entry *proc_dir;
char proc_dir_name[10];
#endif

/* Driver-model device for the system interface. */
Expand Down Expand Up @@ -542,10 +545,6 @@ struct ipmi_smi {
struct ipmi_my_addrinfo addrinfo[IPMI_MAX_CHANNELS];
bool channels_ready;

/* Proc FS stuff. */
struct proc_dir_entry *proc_dir;
char proc_dir_name[10];

atomic_t stats[IPMI_NUM_STATS];

/*
Expand Down Expand Up @@ -2363,7 +2362,7 @@ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
static int smi_ipmb_proc_show(struct seq_file *m, void *v)
{
ipmi_smi_t intf = m->private;
Expand Down Expand Up @@ -2492,14 +2491,12 @@ static const struct file_operations smi_stats_proc_ops = {
.llseek = seq_lseek,
.release = single_release,
};
#endif /* CONFIG_PROC_FS */

int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
const struct file_operations *proc_ops,
void *data)
{
int rv = 0;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *file;
struct ipmi_proc_entry *entry;

Expand All @@ -2525,7 +2522,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
smi->proc_entries = entry;
mutex_unlock(&smi->proc_entry_lock);
}
#endif /* CONFIG_PROC_FS */

return rv;
}
Expand All @@ -2535,7 +2531,6 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
{
int rv = 0;

#ifdef CONFIG_PROC_FS
sprintf(smi->proc_dir_name, "%d", num);
smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
if (!smi->proc_dir)
Expand All @@ -2555,14 +2550,12 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
rv = ipmi_smi_add_proc_entry(smi, "version",
&smi_version_proc_ops,
smi);
#endif /* CONFIG_PROC_FS */

return rv;
}

static void remove_proc_entries(ipmi_smi_t smi)
{
#ifdef CONFIG_PROC_FS
struct ipmi_proc_entry *entry;

mutex_lock(&smi->proc_entry_lock);
Expand All @@ -2576,8 +2569,8 @@ static void remove_proc_entries(ipmi_smi_t smi)
}
mutex_unlock(&smi->proc_entry_lock);
remove_proc_entry(smi->proc_dir_name, proc_ipmi_root);
#endif /* CONFIG_PROC_FS */
}
#endif /* CONFIG_IPMI_PROC_INTERFACE */

static ssize_t device_id_show(struct device *dev,
struct device_attribute *attr,
Expand Down Expand Up @@ -3419,7 +3412,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
intf->seq_table[j].seqid = 0;
}
intf->curr_seq = 0;
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
mutex_init(&intf->proc_entry_lock);
#endif
spin_lock_init(&intf->waiting_rcv_msgs_lock);
Expand All @@ -3443,7 +3436,9 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
for (i = 0; i < IPMI_NUM_STATS; i++)
atomic_set(&intf->stats[i], 0);

#ifdef CONFIG_IPMI_PROC_INTERFACE
intf->proc_dir = NULL;
#endif

mutex_lock(&smi_watchers_mutex);
mutex_lock(&ipmi_interfaces_mutex);
Expand Down Expand Up @@ -3479,13 +3474,17 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
if (rv)
goto out;

#ifdef CONFIG_IPMI_PROC_INTERFACE
rv = add_proc_entries(intf, i);
#endif

out:
if (rv) {
ipmi_bmc_unregister(intf);
#ifdef CONFIG_IPMI_PROC_INTERFACE
if (intf->proc_dir)
remove_proc_entries(intf);
#endif
intf->handlers = NULL;
list_del_rcu(&intf->link);
mutex_unlock(&ipmi_interfaces_mutex);
Expand Down Expand Up @@ -3590,7 +3589,9 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
intf->handlers = NULL;
mutex_unlock(&ipmi_interfaces_mutex);

#ifdef CONFIG_IPMI_PROC_INTERFACE
remove_proc_entries(intf);
#endif
ipmi_bmc_unregister(intf);

/*
Expand Down Expand Up @@ -5170,15 +5171,15 @@ static int ipmi_init_msghandler(void)
printk(KERN_INFO "ipmi message handler version "
IPMI_DRIVER_VERSION "\n");

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
proc_ipmi_root = proc_mkdir("ipmi", NULL);
if (!proc_ipmi_root) {
printk(KERN_ERR PFX "Unable to create IPMI proc dir");
driver_unregister(&ipmidriver.driver);
return -ENOMEM;
}

#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_IPMI_PROC_INTERFACE */

setup_timer(&ipmi_timer, ipmi_timeout, 0);
mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
Expand Down Expand Up @@ -5218,9 +5219,9 @@ static void __exit cleanup_ipmi(void)
atomic_inc(&stop_operation);
del_timer_sync(&ipmi_timer);

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_IPMI_PROC_INTERFACE
proc_remove(proc_ipmi_root);
#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_IPMI_PROC_INTERFACE */

driver_unregister(&ipmidriver.driver);

Expand Down
4 changes: 4 additions & 0 deletions drivers/char/ipmi/ipmi_si_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,7 @@ static int try_enable_event_buffer(struct smi_info *smi_info)
return rv;
}

#ifdef CONFIG_IPMI_PROC_INTERFACE
static int smi_type_proc_show(struct seq_file *m, void *v)
{
struct smi_info *smi = m->private;
Expand Down Expand Up @@ -1698,6 +1699,7 @@ static const struct file_operations smi_params_proc_ops = {
.llseek = seq_lseek,
.release = single_release,
};
#endif

#define IPMI_SI_ATTR(name) \
static ssize_t ipmi_##name##_show(struct device *dev, \
Expand Down Expand Up @@ -2191,6 +2193,7 @@ static int try_smi_init(struct smi_info *new_smi)
goto out_err_remove_attrs;
}

#ifdef CONFIG_IPMI_PROC_INTERFACE
rv = ipmi_smi_add_proc_entry(new_smi->intf, "type",
&smi_type_proc_ops,
new_smi);
Expand All @@ -2217,6 +2220,7 @@ static int try_smi_init(struct smi_info *new_smi)
"Unable to create proc entry: %d\n", rv);
goto out_err_stop_timer;
}
#endif

/* Don't increment till we know we have succeeded. */
smi_num++;
Expand Down
6 changes: 6 additions & 0 deletions drivers/char/ipmi/ipmi_ssif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
return rv;
}

#ifdef CONFIG_IPMI_PROC_INTERFACE
static int smi_type_proc_show(struct seq_file *m, void *v)
{
seq_puts(m, "ssif\n");
Expand Down Expand Up @@ -1407,6 +1408,7 @@ static const struct file_operations smi_stats_proc_ops = {
.llseek = seq_lseek,
.release = single_release,
};
#endif

static int strcmp_nospace(char *s1, char *s2)
{
Expand Down Expand Up @@ -1742,6 +1744,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
goto out_remove_attr;
}

#ifdef CONFIG_IPMI_PROC_INTERFACE
rv = ipmi_smi_add_proc_entry(ssif_info->intf, "type",
&smi_type_proc_ops,
ssif_info);
Expand All @@ -1757,6 +1760,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
pr_err(PFX "Unable to create proc entry: %d\n", rv);
goto out_err_unreg;
}
#endif

out:
if (rv) {
Expand All @@ -1775,8 +1779,10 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
kfree(resp);
return rv;

#ifdef CONFIG_IPMI_PROC_INTERFACE
out_err_unreg:
ipmi_unregister_smi(ssif_info->intf);
#endif

out_remove_attr:
device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group);
Expand Down
2 changes: 2 additions & 0 deletions include/linux/ipmi_smi.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
msg->done(msg);
}

#ifdef CONFIG_IPMI_PROC_INTERFACE
/* Allow the lower layer to add things to the proc filesystem
directory for this interface. Note that the entry will
automatically be dstroyed when the interface is destroyed. */
int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
const struct file_operations *proc_ops,
void *data);
#endif

#endif /* __LINUX_IPMI_SMI_H */

0 comments on commit 55f91cb

Please sign in to comment.