Commit 7d464ed4 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: reduce CONFIG_PROC_FS #ifdef clutter in .c code (from levon@movementarian.org)

parent a203da95
...@@ -1114,12 +1114,10 @@ static int __init atm_init(void) ...@@ -1114,12 +1114,10 @@ static int __init atm_init(void)
printk(KERN_ERR "atmsvc_init() failed with %d\n", error); printk(KERN_ERR "atmsvc_init() failed with %d\n", error);
goto failure; goto failure;
} }
#ifdef CONFIG_PROC_FS
if ((error = atm_proc_init()) < 0) { if ((error = atm_proc_init()) < 0) {
printk(KERN_ERR "atm_proc_init() failed with %d\n",error); printk(KERN_ERR "atm_proc_init() failed with %d\n",error);
goto failure; goto failure;
} }
#endif
return 0; return 0;
failure: failure:
...@@ -1130,9 +1128,7 @@ static int __init atm_init(void) ...@@ -1130,9 +1128,7 @@ static int __init atm_init(void)
static void __exit atm_exit(void) static void __exit atm_exit(void)
{ {
#ifdef CONFIG_PROC_FS
atm_proc_exit(); atm_proc_exit();
#endif
atmsvc_exit(); atmsvc_exit();
atmpvc_exit(); atmpvc_exit();
} }
......
...@@ -33,8 +33,21 @@ int atmpvc_init(void); ...@@ -33,8 +33,21 @@ int atmpvc_init(void);
void atmpvc_exit(void); void atmpvc_exit(void);
int atmsvc_init(void); int atmsvc_init(void);
void atmsvc_exit(void); void atmsvc_exit(void);
#ifdef CONFIG_PROC_FS
int atm_proc_init(void); int atm_proc_init(void);
void atm_proc_exit(void); void atm_proc_exit(void);
#else
static inline int atm_proc_init(void)
{
return 0;
}
static inline void atm_proc_exit(void)
{
/* nothing */
}
#endif /* CONFIG_PROC_FS */
/* SVC */ /* SVC */
......
...@@ -593,6 +593,10 @@ int atm_proc_dev_register(struct atm_dev *dev) ...@@ -593,6 +593,10 @@ int atm_proc_dev_register(struct atm_dev *dev)
int digits,num; int digits,num;
int error; int error;
/* No proc info */
if (!dev->ops->proc_read)
return 0;
error = -ENOMEM; error = -ENOMEM;
digits = 0; digits = 0;
for (num = dev->number; num; num /= 10) digits++; for (num = dev->number; num; num /= 10) digits++;
...@@ -619,6 +623,9 @@ int atm_proc_dev_register(struct atm_dev *dev) ...@@ -619,6 +623,9 @@ int atm_proc_dev_register(struct atm_dev *dev)
void atm_proc_dev_deregister(struct atm_dev *dev) void atm_proc_dev_deregister(struct atm_dev *dev)
{ {
if (!dev->ops->proc_read)
return;
remove_proc_entry(dev->proc_name, atm_proc_root); remove_proc_entry(dev->proc_name, atm_proc_root);
kfree(dev->proc_name); kfree(dev->proc_name);
} }
......
...@@ -110,20 +110,16 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, ...@@ -110,20 +110,16 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
list_add_tail(&dev->dev_list, &atm_devs); list_add_tail(&dev->dev_list, &atm_devs);
spin_unlock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
#ifdef CONFIG_PROC_FS if (atm_proc_dev_register(dev) < 0) {
if (ops->proc_read) { printk(KERN_ERR "atm_dev_register: "
if (atm_proc_dev_register(dev) < 0) { "atm_proc_dev_register failed for dev %s\n",
printk(KERN_ERR "atm_dev_register: " type);
"atm_proc_dev_register failed for dev %s\n", spin_lock(&atm_dev_lock);
type); list_del(&dev->dev_list);
spin_lock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
list_del(&dev->dev_list); __free_atm_dev(dev);
spin_unlock(&atm_dev_lock); return NULL;
__free_atm_dev(dev);
return NULL;
}
} }
#endif
return dev; return dev;
} }
...@@ -133,10 +129,8 @@ void atm_dev_deregister(struct atm_dev *dev) ...@@ -133,10 +129,8 @@ void atm_dev_deregister(struct atm_dev *dev)
{ {
unsigned long warning_time; unsigned long warning_time;
#ifdef CONFIG_PROC_FS atm_proc_dev_deregister(dev);
if (dev->ops->proc_read)
atm_proc_dev_deregister(dev);
#endif
spin_lock(&atm_dev_lock); spin_lock(&atm_dev_lock);
list_del(&dev->dev_list); list_del(&dev->dev_list);
spin_unlock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
......
...@@ -24,6 +24,18 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg); ...@@ -24,6 +24,18 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg);
int atm_proc_dev_register(struct atm_dev *dev); int atm_proc_dev_register(struct atm_dev *dev);
void atm_proc_dev_deregister(struct atm_dev *dev); void atm_proc_dev_deregister(struct atm_dev *dev);
#endif #else
static inline int atm_proc_dev_register(struct atm_dev *dev)
{
return 0;
}
static inline void atm_proc_dev_deregister(struct atm_dev *dev)
{
/* nothing */
}
#endif /* CONFIG_PROC_FS */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment