From b385a144ee790f00e8559bcb8024d042863f9be1 Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Sat, 10 Feb 2007 01:46:25 -0800 Subject: [PATCH] Replace regular code with appropriate calls to container_of() Replace a small number of expressions with a call to the "container_of()" macro. Signed-off-by: Robert P. J. Day Acked-by: Paul Mackerras Cc: "David S. Miller" Cc: Martin Schwidefsky Cc: Stephen Smalley Cc: James Morris Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/ppp_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net') diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index c6de566188e..0986f6c843e 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -83,7 +83,7 @@ struct ppp_file { int dead; /* unit/channel has been shut down */ }; -#define PF_TO_X(pf, X) ((X *)((char *)(pf) - offsetof(X, file))) +#define PF_TO_X(pf, X) container_of(pf, X, file) #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp) #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel) -- cgit v1.2.3 From 2a10387ec463c4fcd3ccc461291ce4d8505827e2 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 12 Feb 2007 00:52:22 -0800 Subject: [PATCH] com20020 build fix Need to export com20020 symbols for com20020_cs also. WARNING: "com20020_found" [drivers/net/pcmcia/com20020_cs.ko] undefined! WARNING: "com20020_check" [drivers/net/pcmcia/com20020_cs.ko] undefined! Signed-off-by: Randy Dunlap Cc: Esben Nielsen Cc: Jeff Garzik Cc: Dominik Brodowski Cc: "David S. Miller" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/arcnet/com20020.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net') diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c index aa9dd8f1126..4218075c8aa 100644 --- a/drivers/net/arcnet/com20020.c +++ b/drivers/net/arcnet/com20020.c @@ -338,7 +338,8 @@ static void com20020_set_mc_list(struct net_device *dev) } #if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \ - defined(CONFIG_ARCNET_COM20020_ISA_MODULE) + defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \ + defined(CONFIG_ARCNET_COM20020_CS_MODULE) EXPORT_SYMBOL(com20020_check); EXPORT_SYMBOL(com20020_found); #endif -- cgit v1.2.3 From d54b1fdb1d9f82e375a299e22bd366aad52d4c34 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 12 Feb 2007 00:55:34 -0800 Subject: [PATCH] mark struct file_operations const 5 Many struct file_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/bonding/bond_main.c | 2 +- drivers/net/hamradio/bpqether.c | 2 +- drivers/net/hamradio/scc.c | 2 +- drivers/net/hamradio/yam.c | 2 +- drivers/net/ibmveth.c | 2 +- drivers/net/irda/vlsi_ir.c | 2 +- drivers/net/ppp_generic.c | 2 +- drivers/net/pppoe.c | 2 +- drivers/net/tun.c | 2 +- drivers/net/wan/cosa.c | 2 +- drivers/net/wireless/airo.c | 16 ++++++++-------- drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c | 12 ++++++------ drivers/net/wireless/strip.c | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 8ce8fec615b..61a6fa465d7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3120,7 +3120,7 @@ static int bond_info_open(struct inode *inode, struct file *file) return res; } -static struct file_operations bond_info_fops = { +static const struct file_operations bond_info_fops = { .owner = THIS_MODULE, .open = bond_info_open, .read = seq_read, diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 5b788d84011..d2542697e29 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -459,7 +459,7 @@ static int bpq_info_open(struct inode *inode, struct file *file) return seq_open(file, &bpq_seqops); } -static struct file_operations bpq_info_fops = { +static const struct file_operations bpq_info_fops = { .owner = THIS_MODULE, .open = bpq_info_open, .read = seq_read, diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c index 2ce047e9d26..6fdaad5a457 100644 --- a/drivers/net/hamradio/scc.c +++ b/drivers/net/hamradio/scc.c @@ -2083,7 +2083,7 @@ static int scc_net_seq_open(struct inode *inode, struct file *file) return seq_open(file, &scc_net_seq_ops); } -static struct file_operations scc_net_seq_fops = { +static const struct file_operations scc_net_seq_fops = { .owner = THIS_MODULE, .open = scc_net_seq_open, .read = seq_read, diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c index 6d74f08720d..08f27119a80 100644 --- a/drivers/net/hamradio/yam.c +++ b/drivers/net/hamradio/yam.c @@ -804,7 +804,7 @@ static int yam_info_open(struct inode *inode, struct file *file) return seq_open(file, &yam_seqops); } -static struct file_operations yam_info_fops = { +static const struct file_operations yam_info_fops = { .owner = THIS_MODULE, .open = yam_info_open, .read = seq_read, diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 99343b5836b..458db0538a9 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c @@ -1156,7 +1156,7 @@ static int ibmveth_proc_open(struct inode *inode, struct file *file) return rc; } -static struct file_operations ibmveth_proc_fops = { +static const struct file_operations ibmveth_proc_fops = { .owner = THIS_MODULE, .open = ibmveth_proc_open, .read = seq_read, diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index e2b1af61845..3457e9d8b66 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c @@ -385,7 +385,7 @@ static int vlsi_seq_open(struct inode *inode, struct file *file) return single_open(file, vlsi_seq_show, PDE(inode)->data); } -static struct file_operations vlsi_proc_fops = { +static const struct file_operations vlsi_proc_fops = { .owner = THIS_MODULE, .open = vlsi_seq_open, .read = seq_read, diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 0986f6c843e..11b575f8985 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -834,7 +834,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, return err; } -static struct file_operations ppp_device_fops = { +static const struct file_operations ppp_device_fops = { .owner = THIS_MODULE, .read = ppp_read, .write = ppp_write, diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 315d5c3fc66..860bb0f60f6 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -1043,7 +1043,7 @@ static int pppoe_seq_open(struct inode *inode, struct file *file) return seq_open(file, &pppoe_seq_ops); } -static struct file_operations pppoe_seq_fops = { +static const struct file_operations pppoe_seq_fops = { .owner = THIS_MODULE, .open = pppoe_seq_open, .read = seq_read, diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 151a2e10e4f..5643d1e84ed 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -744,7 +744,7 @@ static int tun_chr_close(struct inode *inode, struct file *file) return 0; } -static struct file_operations tun_fops = { +static const struct file_operations tun_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = do_sync_read, diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 6c7dfb50143..e91b5a84a20 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -311,7 +311,7 @@ static int cosa_chardev_ioctl(struct inode *inode, struct file *file, static int cosa_fasync(struct inode *inode, struct file *file, int on); #endif -static struct file_operations cosa_fops = { +static const struct file_operations cosa_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = cosa_read, diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 44a22701da9..b08055abe83 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4430,53 +4430,53 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ); static int proc_config_open( struct inode *inode, struct file *file ); static int proc_wepkey_open( struct inode *inode, struct file *file ); -static struct file_operations proc_statsdelta_ops = { +static const struct file_operations proc_statsdelta_ops = { .read = proc_read, .open = proc_statsdelta_open, .release = proc_close }; -static struct file_operations proc_stats_ops = { +static const struct file_operations proc_stats_ops = { .read = proc_read, .open = proc_stats_open, .release = proc_close }; -static struct file_operations proc_status_ops = { +static const struct file_operations proc_status_ops = { .read = proc_read, .open = proc_status_open, .release = proc_close }; -static struct file_operations proc_SSID_ops = { +static const struct file_operations proc_SSID_ops = { .read = proc_read, .write = proc_write, .open = proc_SSID_open, .release = proc_close }; -static struct file_operations proc_BSSList_ops = { +static const struct file_operations proc_BSSList_ops = { .read = proc_read, .write = proc_write, .open = proc_BSSList_open, .release = proc_close }; -static struct file_operations proc_APList_ops = { +static const struct file_operations proc_APList_ops = { .read = proc_read, .write = proc_write, .open = proc_APList_open, .release = proc_close }; -static struct file_operations proc_config_ops = { +static const struct file_operations proc_config_ops = { .read = proc_read, .write = proc_write, .open = proc_config_open, .release = proc_close }; -static struct file_operations proc_wepkey_ops = { +static const struct file_operations proc_wepkey_ops = { .read = proc_read, .write = proc_write, .open = proc_wepkey_open, diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c index b9df06a06ea..35dbe455451 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c @@ -355,37 +355,37 @@ out_up: #undef fappend -static struct file_operations devinfo_fops = { +static const struct file_operations devinfo_fops = { .read = devinfo_read_file, .write = write_file_dummy, .open = open_file_generic, }; -static struct file_operations spromdump_fops = { +static const struct file_operations spromdump_fops = { .read = spromdump_read_file, .write = write_file_dummy, .open = open_file_generic, }; -static struct file_operations drvinfo_fops = { +static const struct file_operations drvinfo_fops = { .read = drvinfo_read_file, .write = write_file_dummy, .open = open_file_generic, }; -static struct file_operations tsf_fops = { +static const struct file_operations tsf_fops = { .read = tsf_read_file, .write = tsf_write_file, .open = open_file_generic, }; -static struct file_operations txstat_fops = { +static const struct file_operations txstat_fops = { .read = txstat_read_file, .write = write_file_dummy, .open = open_file_generic, }; -static struct file_operations restart_fops = { +static const struct file_operations restart_fops = { .write = restart_write_file, .open = open_file_generic, }; diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index ce3a8bac66f..f5ce1c6063d 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c @@ -1160,7 +1160,7 @@ static int strip_seq_open(struct inode *inode, struct file *file) return seq_open(file, &strip_seq_ops); } -static struct file_operations strip_seq_fops = { +static const struct file_operations strip_seq_fops = { .owner = THIS_MODULE, .open = strip_seq_open, .read = seq_read, -- cgit v1.2.3 From 4409d28140d9a6e6e3f4f1fdaf7234c4b965d954 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 12 Feb 2007 23:40:06 -0600 Subject: Convert network devices to use struct device instead of class_device Convert network devices to use struct device instead of class_device. Greg missed this one in his cleanup path. Signed-off-by: Kumar Gala --- drivers/net/gianfar_sysfs.c | 108 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index 9dd387fb3d7..6e2166a7601 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c @@ -39,13 +39,15 @@ #include "gianfar.h" #define GFAR_ATTR(_name) \ -static ssize_t gfar_show_##_name(struct class_device *cdev, char *buf); \ -static ssize_t gfar_set_##_name(struct class_device *cdev, \ +static ssize_t gfar_show_##_name(struct device *dev, \ + struct device_attribute *attr, char *buf); \ +static ssize_t gfar_set_##_name(struct device *dev, \ + struct device_attribute *attr, \ const char *buf, size_t count); \ -static CLASS_DEVICE_ATTR(_name, 0644, gfar_show_##_name, gfar_set_##_name) +static DEVICE_ATTR(_name, 0644, gfar_show_##_name, gfar_set_##_name) #define GFAR_CREATE_FILE(_dev, _name) \ - class_device_create_file(&_dev->class_dev, &class_device_attr_##_name) + device_create_file(&_dev->dev, &dev_attr_##_name) GFAR_ATTR(bd_stash); GFAR_ATTR(rx_stash_size); @@ -54,29 +56,28 @@ GFAR_ATTR(fifo_threshold); GFAR_ATTR(fifo_starve); GFAR_ATTR(fifo_starve_off); -#define to_net_dev(cd) container_of(cd, struct net_device, class_dev) - -static ssize_t gfar_show_bd_stash(struct class_device *cdev, char *buf) +static ssize_t gfar_show_bd_stash(struct device *dev, + struct device_attribute *attr, char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); - return sprintf(buf, "%s\n", priv->bd_stash_en? "on" : "off"); + return sprintf(buf, "%s\n", priv->bd_stash_en ? "on" : "off"); } -static ssize_t gfar_set_bd_stash(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_bd_stash(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); int new_setting = 0; u32 temp; unsigned long flags; /* Find out the new setting */ - if (!strncmp("on", buf, count-1) || !strncmp("1", buf, count-1)) + if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) new_setting = 1; - else if (!strncmp("off", buf, count-1) || !strncmp("0", buf, count-1)) + else if (!strncmp("off", buf, count - 1) + || !strncmp("0", buf, count - 1)) new_setting = 0; else return count; @@ -100,19 +101,19 @@ static ssize_t gfar_set_bd_stash(struct class_device *cdev, return count; } -static ssize_t gfar_show_rx_stash_size(struct class_device *cdev, char *buf) +static ssize_t gfar_show_rx_stash_size(struct device *dev, + struct device_attribute *attr, char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); return sprintf(buf, "%d\n", priv->rx_stash_size); } -static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_rx_stash_size(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned int length = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; @@ -146,21 +147,21 @@ static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, return count; } - /* Stashing will only be enabled when rx_stash_size != 0 */ -static ssize_t gfar_show_rx_stash_index(struct class_device *cdev, char *buf) +static ssize_t gfar_show_rx_stash_index(struct device *dev, + struct device_attribute *attr, + char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); return sprintf(buf, "%d\n", priv->rx_stash_index); } -static ssize_t gfar_set_rx_stash_index(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_rx_stash_index(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned short index = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; @@ -184,19 +185,20 @@ static ssize_t gfar_set_rx_stash_index(struct class_device *cdev, return count; } -static ssize_t gfar_show_fifo_threshold(struct class_device *cdev, char *buf) +static ssize_t gfar_show_fifo_threshold(struct device *dev, + struct device_attribute *attr, + char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); return sprintf(buf, "%d\n", priv->fifo_threshold); } -static ssize_t gfar_set_fifo_threshold(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_fifo_threshold(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned int length = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; @@ -218,20 +220,19 @@ static ssize_t gfar_set_fifo_threshold(struct class_device *cdev, return count; } -static ssize_t gfar_show_fifo_starve(struct class_device *cdev, char *buf) +static ssize_t gfar_show_fifo_starve(struct device *dev, + struct device_attribute *attr, char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); return sprintf(buf, "%d\n", priv->fifo_starve); } - -static ssize_t gfar_set_fifo_starve(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_fifo_starve(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned int num = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; @@ -253,19 +254,20 @@ static ssize_t gfar_set_fifo_starve(struct class_device *cdev, return count; } -static ssize_t gfar_show_fifo_starve_off(struct class_device *cdev, char *buf) +static ssize_t gfar_show_fifo_starve_off(struct device *dev, + struct device_attribute *attr, + char *buf) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); return sprintf(buf, "%d\n", priv->fifo_starve_off); } -static ssize_t gfar_set_fifo_starve_off(struct class_device *cdev, - const char *buf, size_t count) +static ssize_t gfar_set_fifo_starve_off(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct net_device *dev = to_net_dev(cdev); - struct gfar_private *priv = netdev_priv(dev); + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned int num = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; -- cgit v1.2.3