2009-12-04 21:58:27

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 00/31] constify various _ops structures for 2.6.32 v1

Hello everyone!

The following patch series attempts to constify several structures
that hold function pointers. This is only the initial batch, there
are about over 150 candidate structures, some of which can be
constified as well, I plan to submit them in the future.

The list of constified structures in this series:
acpi_dock_ops
address_space_operations
backlight_ops
block_device_operations
dma_map_ops
e1000_mac_operations
e1000_nvm_operations
e1000_phy_operations
extent_io_ops
file_lock_operations
file_operations
hv_ops
intel_dvo_dev_ops
item_operations
iwl_ops
kgdb_arch
kgdb_io
kset_uevent_ops
lock_manager_operations
microcode_ops
mtrr_ops
neigh_ops
nlmsvc_binding
pci_raw_ops
platform_hibernation_ops
platform_suspend_ops
snd_ac97_build_ops
super_operations
sysfs_ops
usb_mon_operations
wd_ops

There are certain exceptions where a given instance of the structure
cannot be const, they are marked with a comment in the patch.

The patches compile fine with an allyesconfig kernel on i386 and x86_64.

Please let me know if any of these structures should not be constified
and any other issues you see with them.

Thanks,
Emese


2009-12-04 22:04:25

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 01/31] Constify struct acpi_dock_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct acpi_dock_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/dock.c | 4 ++--
drivers/ata/libata-acpi.c | 4 ++--
drivers/pci/hotplug/acpiphp_glue.c | 2 +-
include/acpi/acpi_drivers.h | 8 ++++----
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 7338b6a..82f0257 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -77,7 +77,7 @@ struct dock_dependent_device {
struct list_head list;
struct list_head hotplug_list;
acpi_handle handle;
- struct acpi_dock_ops *ops;
+ const struct acpi_dock_ops *ops;
void *context;
};

@@ -605,7 +605,7 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifier);
* the dock driver after _DCK is executed.
*/
int
-register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
+register_hotplug_dock_device(acpi_handle handle, const struct acpi_dock_ops *ops,
void *context)
{
struct dock_dependent_device *dd;
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index b0882cd..c295d65 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -223,12 +223,12 @@ static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
ata_acpi_uevent(dev->link->ap, dev, event);
}

-static struct acpi_dock_ops ata_acpi_dev_dock_ops = {
+static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
.handler = ata_acpi_dev_notify_dock,
.uevent = ata_acpi_dev_uevent,
};

-static struct acpi_dock_ops ata_acpi_ap_dock_ops = {
+static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
.handler = ata_acpi_ap_notify_dock,
.uevent = ata_acpi_ap_uevent,
};
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 58d25a1..3e5aacb 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -111,7 +111,7 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
}


-static struct acpi_dock_ops acpiphp_dock_ops = {
+static const struct acpi_dock_ops acpiphp_dock_ops = {
.handler = handle_hotplug_event_func,
};

diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index f4906f6..71feb73 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -119,8 +119,8 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
Dock Station
-------------------------------------------------------------------------- */
struct acpi_dock_ops {
- acpi_notify_handler handler;
- acpi_notify_handler uevent;
+ const acpi_notify_handler handler;
+ const acpi_notify_handler uevent;
};

#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
@@ -128,7 +128,7 @@ extern int is_dock_device(acpi_handle handle);
extern int register_dock_notifier(struct notifier_block *nb);
extern void unregister_dock_notifier(struct notifier_block *nb);
extern int register_hotplug_dock_device(acpi_handle handle,
- struct acpi_dock_ops *ops,
+ const struct acpi_dock_ops *ops,
void *context);
extern void unregister_hotplug_dock_device(acpi_handle handle);
#else
@@ -144,7 +144,7 @@ static inline void unregister_dock_notifier(struct notifier_block *nb)
{
}
static inline int register_hotplug_dock_device(acpi_handle handle,
- struct acpi_dock_ops *ops,
+ const struct acpi_dock_ops *ops,
void *context)
{
return -ENODEV;

2009-12-04 22:06:21

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 02/31] Constify struct address_space_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct address_space_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
include/linux/fs.h | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2620a8c..1a55cac 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -565,41 +565,41 @@ typedef int (*read_actor_t)(read_descriptor_t *, struct page *,
unsigned long, unsigned long);

struct address_space_operations {
- int (*writepage)(struct page *page, struct writeback_control *wbc);
- int (*readpage)(struct file *, struct page *);
- void (*sync_page)(struct page *);
+ int (* const writepage)(struct page *page, struct writeback_control *wbc);
+ int (* const readpage)(struct file *, struct page *);
+ void (* const sync_page)(struct page *);

/* Write back some dirty pages from this mapping. */
- int (*writepages)(struct address_space *, struct writeback_control *);
+ int (* const writepages)(struct address_space *, struct writeback_control *);

/* Set a page dirty. Return true if this dirtied it */
- int (*set_page_dirty)(struct page *page);
+ int (* const set_page_dirty)(struct page *page);

- int (*readpages)(struct file *filp, struct address_space *mapping,
+ int (* const readpages)(struct file *filp, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages);

- int (*write_begin)(struct file *, struct address_space *mapping,
+ int (* const write_begin)(struct file *, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata);
- int (*write_end)(struct file *, struct address_space *mapping,
+ int (* const write_end)(struct file *, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata);

/* Unfortunately this kludge is needed for FIBMAP. Don't use it */
- sector_t (*bmap)(struct address_space *, sector_t);
- void (*invalidatepage) (struct page *, unsigned long);
- int (*releasepage) (struct page *, gfp_t);
- ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
+ sector_t (* const bmap)(struct address_space *, sector_t);
+ void (* const invalidatepage) (struct page *, unsigned long);
+ int (* const releasepage) (struct page *, gfp_t);
+ ssize_t (* const direct_IO)(int, struct kiocb *, const struct iovec *iov,
loff_t offset, unsigned long nr_segs);
- int (*get_xip_mem)(struct address_space *, pgoff_t, int,
+ int (* const get_xip_mem)(struct address_space *, pgoff_t, int,
void **, unsigned long *);
/* migrate the contents of a page to the specified target */
- int (*migratepage) (struct address_space *,
+ int (* const migratepage) (struct address_space *,
struct page *, struct page *);
- int (*launder_page) (struct page *);
- int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
+ int (* const launder_page) (struct page *);
+ int (* const is_partially_uptodate) (struct page *, read_descriptor_t *,
unsigned long);
- int (*error_remove_page)(struct address_space *, struct page *);
+ int (* const error_remove_page)(struct address_space *, struct page *);
};

/*

2009-12-04 22:08:51

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 03/31] Constify struct backlight_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct backlight_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/video.c | 2 +-
drivers/macintosh/via-pmu-backlight.c | 4 ++--
drivers/platform/x86/acer-wmi.c | 2 +-
drivers/platform/x86/asus-laptop.c | 2 +-
drivers/platform/x86/asus_acpi.c | 2 +-
drivers/platform/x86/compal-laptop.c | 2 +-
drivers/platform/x86/dell-laptop.c | 2 +-
drivers/platform/x86/eeepc-laptop.c | 2 +-
drivers/platform/x86/fujitsu-laptop.c | 2 +-
drivers/platform/x86/msi-laptop.c | 2 +-
drivers/platform/x86/panasonic-laptop.c | 2 +-
drivers/platform/x86/sony-laptop.c | 2 +-
drivers/platform/x86/thinkpad_acpi.c | 2 +-
drivers/platform/x86/toshiba_acpi.c | 2 +-
drivers/usb/misc/appledisplay.c | 2 +-
drivers/video/atmel_lcdfb.c | 2 +-
drivers/video/aty/aty128fb.c | 2 +-
drivers/video/aty/atyfb_base.c | 2 +-
drivers/video/aty/radeon_backlight.c | 2 +-
drivers/video/backlight/adp5520_bl.c | 2 +-
drivers/video/backlight/adx_bl.c | 2 +-
drivers/video/backlight/atmel-pwm-bl.c | 2 +-
drivers/video/backlight/backlight.c | 2 +-
drivers/video/backlight/corgi_lcd.c | 2 +-
drivers/video/backlight/cr_bllcd.c | 2 +-
drivers/video/backlight/da903x_bl.c | 2 +-
drivers/video/backlight/generic_bl.c | 2 +-
drivers/video/backlight/hp680_bl.c | 2 +-
drivers/video/backlight/jornada720_bl.c | 2 +-
drivers/video/backlight/kb3886_bl.c | 2 +-
drivers/video/backlight/locomolcd.c | 2 +-
drivers/video/backlight/mbp_nvidia_bl.c | 2 +-
drivers/video/backlight/omap1_bl.c | 2 +-
drivers/video/backlight/progear_bl.c | 2 +-
drivers/video/backlight/pwm_bl.c | 2 +-
drivers/video/backlight/tosa_bl.c | 2 +-
drivers/video/backlight/wm831x_bl.c | 2 +-
drivers/video/bf54x-lq043fb.c | 2 +-
drivers/video/bfin-t350mcqb-fb.c | 2 +-
drivers/video/nvidia/nv_backlight.c | 2 +-
drivers/video/riva/fbdev.c | 2 +-
include/linux/backlight.h | 12 ++++++------
42 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 05dff63..b662ab7 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -359,7 +359,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd)
vd->brightness->levels[request_level]);
}

-static struct backlight_ops acpi_backlight_ops = {
+static const struct backlight_ops acpi_backlight_ops = {
.get_brightness = acpi_video_get_brightness,
.update_status = acpi_video_set_brightness,
};
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c
index a348bb0..ecd9b3f 100644
--- a/drivers/macintosh/via-pmu-backlight.c
+++ b/drivers/macintosh/via-pmu-backlight.c
@@ -15,7 +15,7 @@

#define MAX_PMU_LEVEL 0xFF

-static struct backlight_ops pmu_backlight_data;
+static const struct backlight_ops pmu_backlight_data;
static DEFINE_SPINLOCK(pmu_backlight_lock);
static int sleeping, uses_pmu_bl;
static u8 bl_curve[FB_BACKLIGHT_LEVELS];
@@ -115,7 +115,7 @@ static int pmu_backlight_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops pmu_backlight_data = {
+static const struct backlight_ops pmu_backlight_data = {
.get_brightness = pmu_backlight_get_brightness,
.update_status = pmu_backlight_update_status,

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 454970d..98f0e9a 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -918,7 +918,7 @@ static int update_bl_status(struct backlight_device *bd)
return 0;
}

-static struct backlight_ops acer_bl_ops = {
+static const struct backlight_ops acer_bl_ops = {
.get_brightness = read_brightness,
.update_status = update_bl_status,
};
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index b39d2bb..c9a3dc4 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -249,7 +249,7 @@ static struct backlight_device *asus_backlight_device;
*/
static int read_brightness(struct backlight_device *bd);
static int update_bl_status(struct backlight_device *bd);
-static struct backlight_ops asusbl_ops = {
+static const struct backlight_ops asusbl_ops = {
.get_brightness = read_brightness,
.update_status = update_bl_status,
};
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index ddf5240..61e6673 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -1402,7 +1402,7 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
return 0;
}

-static struct backlight_ops asus_backlight_data = {
+static const struct backlight_ops asus_backlight_data = {
.get_brightness = read_brightness,
.update_status = set_brightness_status,
};
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 11003bb..550ff1b 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -163,7 +163,7 @@ static int bl_update_status(struct backlight_device *b)
return set_lcd_level(b->props.brightness);
}

-static struct backlight_ops compalbl_ops = {
+static const struct backlight_ops compalbl_ops = {
.get_brightness = bl_get_brightness,
.update_status = bl_update_status,
};
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 74909c4..e1ac2ba 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -305,7 +305,7 @@ static int dell_get_intensity(struct backlight_device *bd)
return buffer.output[1];
}

-static struct backlight_ops dell_ops = {
+static const struct backlight_ops dell_ops = {
.get_brightness = dell_get_intensity,
.update_status = dell_send_intensity,
};
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 4226e53..387aad9 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -242,7 +242,7 @@ static struct device *eeepc_hwmon_device;
*/
static int read_brightness(struct backlight_device *bd);
static int update_bl_status(struct backlight_device *bd);
-static struct backlight_ops eeepcbl_ops = {
+static const struct backlight_ops eeepcbl_ops = {
.get_brightness = read_brightness,
.update_status = update_bl_status,
};
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index bcd4ba8..a249b35 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -436,7 +436,7 @@ static int bl_update_status(struct backlight_device *b)
return ret;
}

-static struct backlight_ops fujitsubl_ops = {
+static const struct backlight_ops fujitsubl_ops = {
.get_brightness = bl_get_brightness,
.update_status = bl_update_status,
};
diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
index 759763d..1093ba2 100644
--- a/drivers/platform/x86/msi-laptop.c
+++ b/drivers/platform/x86/msi-laptop.c
@@ -161,7 +161,7 @@ static int bl_update_status(struct backlight_device *b)
return set_lcd_level(b->props.brightness);
}

-static struct backlight_ops msibl_ops = {
+static const struct backlight_ops msibl_ops = {
.get_brightness = bl_get_brightness,
.update_status = bl_update_status,
};
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index fe7cf01..9012d8d 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -352,7 +352,7 @@ static int bl_set_status(struct backlight_device *bd)
return acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, bright);
}

-static struct backlight_ops pcc_backlight_ops = {
+static const struct backlight_ops pcc_backlight_ops = {
.get_brightness = bl_get,
.update_status = bl_set_status,
};
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index a2a742c..b37e25e 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -850,7 +850,7 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
}

static struct backlight_device *sony_backlight_device;
-static struct backlight_ops sony_backlight_ops = {
+static const struct backlight_ops sony_backlight_ops = {
.update_status = sony_backlight_update_status,
.get_brightness = sony_backlight_get_brightness,
};
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index a848c7e..1c42bc6 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -6095,7 +6095,7 @@ static int brightness_get(struct backlight_device *bd)
return status & TP_EC_BACKLIGHT_LVLMSK;
}

-static struct backlight_ops ibm_backlight_data = {
+static const struct backlight_ops ibm_backlight_data = {
.get_brightness = brightness_get,
.update_status = brightness_update_status,
};
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 51c0a8b..0786629 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -671,7 +671,7 @@ static acpi_status remove_device(void)
return AE_OK;
}

-static struct backlight_ops toshiba_backlight_data = {
+static const struct backlight_ops toshiba_backlight_data = {
.get_brightness = get_lcd,
.update_status = set_lcd_status,
};
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 1d8e39a..7aef786 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -178,7 +178,7 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
return pdata->msgdata[1];
}

-static struct backlight_ops appledisplay_bl_data = {
+static const struct backlight_ops appledisplay_bl_data = {
.get_brightness = appledisplay_bl_get_brightness,
.update_status = appledisplay_bl_update_status,
};
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index d5e8010..5687b56 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -110,7 +110,7 @@ static int atmel_bl_get_brightness(struct backlight_device *bl)
return lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
}

-static struct backlight_ops atmel_lcdc_bl_ops = {
+static const struct backlight_ops atmel_lcdc_bl_ops = {
.update_status = atmel_bl_update_status,
.get_brightness = atmel_bl_get_brightness,
};
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index e4e4d43..137cd34 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1787,7 +1787,7 @@ static int aty128_bl_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops aty128_bl_data = {
+static const struct backlight_ops aty128_bl_data = {
.get_brightness = aty128_bl_get_brightness,
.update_status = aty128_bl_update_status,
};
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 913b4a4..9295a38 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2225,7 +2225,7 @@ static int aty_bl_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops aty_bl_data = {
+static const struct backlight_ops aty_bl_data = {
.get_brightness = aty_bl_get_brightness,
.update_status = aty_bl_update_status,
};
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 1a056ad..221bd6a 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -127,7 +127,7 @@ static int radeon_bl_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops radeon_bl_data = {
+static const struct backlight_ops radeon_bl_data = {
.get_brightness = radeon_bl_get_brightness,
.update_status = radeon_bl_update_status,
};
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index ad05da5..3cb2cb9 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -84,7 +84,7 @@ static int adp5520_bl_get_brightness(struct backlight_device *bl)
return error ? data->current_brightness : reg_val;
}

-static struct backlight_ops adp5520_bl_ops = {
+static const struct backlight_ops adp5520_bl_ops = {
.update_status = adp5520_bl_update_status,
.get_brightness = adp5520_bl_get_brightness,
};
diff --git a/drivers/video/backlight/adx_bl.c b/drivers/video/backlight/adx_bl.c
index 2c3bdfc..d769b0b 100644
--- a/drivers/video/backlight/adx_bl.c
+++ b/drivers/video/backlight/adx_bl.c
@@ -61,7 +61,7 @@ static int adx_backlight_check_fb(struct fb_info *fb)
return 1;
}

-static struct backlight_ops adx_backlight_ops = {
+static const struct backlight_ops adx_backlight_ops = {
.options = 0,
.update_status = adx_backlight_update_status,
.get_brightness = adx_backlight_get_brightness,
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
index 505c082..6b6b3cc 100644
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ b/drivers/video/backlight/atmel-pwm-bl.c
@@ -113,7 +113,7 @@ static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl)
return pwm_channel_enable(&pwmbl->pwmc);
}

-static struct backlight_ops atmel_pwm_bl_ops = {
+static const struct backlight_ops atmel_pwm_bl_ops = {
.get_brightness = atmel_pwm_bl_get_intensity,
.update_status = atmel_pwm_bl_set_intensity,
};
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 6615ac7..18829cf 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(backlight_force_update);
* ERR_PTR() or a pointer to the newly allocated device.
*/
struct backlight_device *backlight_device_register(const char *name,
- struct device *parent, void *devdata, struct backlight_ops *ops)
+ struct device *parent, void *devdata, const struct backlight_ops *ops)
{
struct backlight_device *new_bd;
int rc;
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 9677494..b4bcf80 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -451,7 +451,7 @@ void corgi_lcd_limit_intensity(int limit)
}
EXPORT_SYMBOL(corgi_lcd_limit_intensity);

-static struct backlight_ops corgi_bl_ops = {
+static const struct backlight_ops corgi_bl_ops = {
.get_brightness = corgi_bl_get_intensity,
.update_status = corgi_bl_update_status,
};
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index b9fe62b..2914bf1 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -108,7 +108,7 @@ static int cr_backlight_get_intensity(struct backlight_device *bd)
return intensity;
}

-static struct backlight_ops cr_backlight_ops = {
+static const struct backlight_ops cr_backlight_ops = {
.get_brightness = cr_backlight_get_intensity,
.update_status = cr_backlight_set_intensity,
};
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 701a108..feacfd5 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -94,7 +94,7 @@ static int da903x_backlight_get_brightness(struct backlight_device *bl)
return data->current_brightness;
}

-static struct backlight_ops da903x_backlight_ops = {
+static const struct backlight_ops da903x_backlight_ops = {
.update_status = da903x_backlight_update_status,
.get_brightness = da903x_backlight_get_brightness,
};
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
index 6d27f62..e6d348e 100644
--- a/drivers/video/backlight/generic_bl.c
+++ b/drivers/video/backlight/generic_bl.c
@@ -70,7 +70,7 @@ void corgibl_limit_intensity(int limit)
}
EXPORT_SYMBOL(corgibl_limit_intensity);

-static struct backlight_ops genericbl_ops = {
+static const struct backlight_ops genericbl_ops = {
.options = BL_CORE_SUSPENDRESUME,
.get_brightness = genericbl_get_intensity,
.update_status = genericbl_send_intensity,
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index 7fb4eef..f7cc528 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -98,7 +98,7 @@ static int hp680bl_get_intensity(struct backlight_device *bd)
return current_intensity;
}

-static struct backlight_ops hp680bl_ops = {
+static const struct backlight_ops hp680bl_ops = {
.get_brightness = hp680bl_get_intensity,
.update_status = hp680bl_set_intensity,
};
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
index 7aed256..db9071f 100644
--- a/drivers/video/backlight/jornada720_bl.c
+++ b/drivers/video/backlight/jornada720_bl.c
@@ -93,7 +93,7 @@ out:
return ret;
}

-static struct backlight_ops jornada_bl_ops = {
+static const struct backlight_ops jornada_bl_ops = {
.get_brightness = jornada_bl_get_brightness,
.update_status = jornada_bl_update_status,
.options = BL_CORE_SUSPENDRESUME,
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
index a38fda1..939e7b8 100644
--- a/drivers/video/backlight/kb3886_bl.c
+++ b/drivers/video/backlight/kb3886_bl.c
@@ -134,7 +134,7 @@ static int kb3886bl_get_intensity(struct backlight_device *bd)
return kb3886bl_intensity;
}

-static struct backlight_ops kb3886bl_ops = {
+static const struct backlight_ops kb3886bl_ops = {
.get_brightness = kb3886bl_get_intensity,
.update_status = kb3886bl_send_intensity,
};
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index 6b488b8..00a9591 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -141,7 +141,7 @@ static int locomolcd_get_intensity(struct backlight_device *bd)
return current_intensity;
}

-static struct backlight_ops locomobl_data = {
+static const struct backlight_ops locomobl_data = {
.get_brightness = locomolcd_get_intensity,
.update_status = locomolcd_set_intensity,
};
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
index 9edb8d7..5812468 100644
--- a/drivers/video/backlight/mbp_nvidia_bl.c
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -33,7 +33,7 @@ struct dmi_match_data {
unsigned long iostart;
unsigned long iolen;
/* Backlight operations structure. */
- struct backlight_ops backlight_ops;
+ const struct backlight_ops backlight_ops;
};

/* Module parameters. */
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index cbad67e..3cf900e 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -125,7 +125,7 @@ static int omapbl_get_intensity(struct backlight_device *dev)
return bl->current_intensity;
}

-static struct backlight_ops omapbl_ops = {
+static const struct backlight_ops omapbl_ops = {
.get_brightness = omapbl_get_intensity,
.update_status = omapbl_update_status,
};
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c
index 9edaf24..075786e 100644
--- a/drivers/video/backlight/progear_bl.c
+++ b/drivers/video/backlight/progear_bl.c
@@ -54,7 +54,7 @@ static int progearbl_get_intensity(struct backlight_device *bd)
return intensity - HW_LEVEL_MIN;
}

-static struct backlight_ops progearbl_ops = {
+static const struct backlight_ops progearbl_ops = {
.get_brightness = progearbl_get_intensity,
.update_status = progearbl_set_intensity,
};
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 8871662..df9e0b3 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -56,7 +56,7 @@ static int pwm_backlight_get_brightness(struct backlight_device *bl)
return bl->props.brightness;
}

-static struct backlight_ops pwm_backlight_ops = {
+static const struct backlight_ops pwm_backlight_ops = {
.update_status = pwm_backlight_update_status,
.get_brightness = pwm_backlight_get_brightness,
};
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index 43edbad..e14ce4d 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -72,7 +72,7 @@ static int tosa_bl_get_brightness(struct backlight_device *dev)
return props->brightness;
}

-static struct backlight_ops bl_ops = {
+static const struct backlight_ops bl_ops = {
.get_brightness = tosa_bl_get_brightness,
.update_status = tosa_bl_update_status,
};
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index 467bdb7..e32add3 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -112,7 +112,7 @@ static int wm831x_backlight_get_brightness(struct backlight_device *bl)
return data->current_brightness;
}

-static struct backlight_ops wm831x_backlight_ops = {
+static const struct backlight_ops wm831x_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = wm831x_backlight_update_status,
.get_brightness = wm831x_backlight_get_brightness,
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index e49ae5e..db4e6f7 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -463,7 +463,7 @@ static int bl_get_brightness(struct backlight_device *bd)
return 0;
}

-static struct backlight_ops bfin_lq043fb_bl_ops = {
+static const struct backlight_ops bfin_lq043fb_bl_ops = {
.get_brightness = bl_get_brightness,
};

diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index 5cc36cf..4e06416 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -381,7 +381,7 @@ static int bl_get_brightness(struct backlight_device *bd)
return 0;
}

-static struct backlight_ops bfin_lq043fb_bl_ops = {
+static const struct backlight_ops bfin_lq043fb_bl_ops = {
.get_brightness = bl_get_brightness,
};

diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 443e3c8..c443d6a 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -87,7 +87,7 @@ static int nvidia_bl_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops nvidia_bl_ops = {
+static const struct backlight_ops nvidia_bl_ops = {
.get_brightness = nvidia_bl_get_brightness,
.update_status = nvidia_bl_update_status,
};
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index d94c57f..912984c 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -331,7 +331,7 @@ static int riva_bl_get_brightness(struct backlight_device *bd)
return bd->props.brightness;
}

-static struct backlight_ops riva_bl_ops = {
+static const struct backlight_ops riva_bl_ops = {
.get_brightness = riva_bl_get_brightness,
.update_status = riva_bl_update_status,
};
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 0f5f578..8c4f884 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -36,18 +36,18 @@ struct backlight_device;
struct fb_info;

struct backlight_ops {
- unsigned int options;
+ const unsigned int options;

#define BL_CORE_SUSPENDRESUME (1 << 0)

/* Notify the backlight driver some property has changed */
- int (*update_status)(struct backlight_device *);
+ int (* const update_status)(struct backlight_device *);
/* Return the current backlight brightness (accounting for power,
fb_blank etc.) */
- int (*get_brightness)(struct backlight_device *);
+ int (* const get_brightness)(struct backlight_device *);
/* Check if given framebuffer device is the one bound to this backlight;
return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
- int (*check_fb)(struct fb_info *);
+ int (* const check_fb)(struct fb_info *);
};

/* This structure defines all the properties of a backlight */
@@ -86,7 +86,7 @@ struct backlight_device {
registered this device has been unloaded, and if class_get_devdata()
points to something in the body of that driver, it is also invalid. */
struct mutex ops_lock;
- struct backlight_ops *ops;
+ const struct backlight_ops *ops;

/* The framebuffer notifier block */
struct notifier_block fb_notif;
@@ -103,7 +103,7 @@ static inline void backlight_update_status(struct backlight_device *bd)
}

extern struct backlight_device *backlight_device_register(const char *name,
- struct device *dev, void *devdata, struct backlight_ops *ops);
+ struct device *dev, void *devdata, const struct backlight_ops *ops);
extern void backlight_device_unregister(struct backlight_device *bd);
extern void backlight_force_update(struct backlight_device *bd,
enum backlight_update_reason reason);

2009-12-04 22:10:09

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 04/31] Constify struct block_device_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct block_device_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/staging/dst/dcore.c | 2 +-
drivers/staging/hv/blkvsc_drv.c | 2 +-
include/linux/blkdev.h | 22 +++++++++++-----------
3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dst/dcore.c b/drivers/staging/dst/dcore.c
index c24e4e0..4f62b69 100644
--- a/drivers/staging/dst/dcore.c
+++ b/drivers/staging/dst/dcore.c
@@ -149,7 +149,7 @@ static int dst_bdev_release(struct gendisk *disk, fmode_t mode)
return 0;
}

-static struct block_device_operations dst_blk_ops = {
+static const struct block_device_operations dst_blk_ops = {
.open = dst_bdev_open,
.release = dst_bdev_release,
.owner = THIS_MODULE,
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 62b2828..0a47695 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -153,7 +153,7 @@ static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE;
/* The one and only one */
static struct blkvsc_driver_context g_blkvsc_drv;

-static struct block_device_operations block_ops = {
+static const struct block_device_operations block_ops = {
.owner = THIS_MODULE,
.open = blkvsc_open,
.release = blkvsc_release,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 221cecd..82f20f0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1253,19 +1253,19 @@ static inline int blk_integrity_rq(struct request *rq)
#endif /* CONFIG_BLK_DEV_INTEGRITY */

struct block_device_operations {
- int (*open) (struct block_device *, fmode_t);
- int (*release) (struct gendisk *, fmode_t);
- int (*locked_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
- int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
- int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
- int (*direct_access) (struct block_device *, sector_t,
+ int (* const open) (struct block_device *, fmode_t);
+ int (* const release) (struct gendisk *, fmode_t);
+ int (* const locked_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
+ int (* const ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
+ int (* const compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
+ int (* const direct_access) (struct block_device *, sector_t,
void **, unsigned long *);
- int (*media_changed) (struct gendisk *);
- unsigned long long (*set_capacity) (struct gendisk *,
+ int (* const media_changed) (struct gendisk *);
+ unsigned long long (* const set_capacity) (struct gendisk *,
unsigned long long);
- int (*revalidate_disk) (struct gendisk *);
- int (*getgeo)(struct block_device *, struct hd_geometry *);
- struct module *owner;
+ int (* const revalidate_disk) (struct gendisk *);
+ int (*const getgeo)(struct block_device *, struct hd_geometry *);
+ const struct module *owner;
};

extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,

2009-12-04 22:12:37

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct dma_map_ops with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/hp/common/hwsw_iommu.c | 4 ++--
arch/ia64/hp/common/sba_iommu.c | 4 ++--
arch/ia64/include/asm/dma-mapping.h | 10 +++++-----
arch/ia64/include/asm/machvec.h | 4 ++--
arch/ia64/kernel/dma-mapping.c | 4 ++--
arch/ia64/kernel/pci-dma.c | 2 +-
arch/ia64/kernel/pci-swiotlb.c | 2 +-
arch/ia64/sn/pci/pci_dma.c | 2 +-
arch/powerpc/include/asm/device.h | 2 +-
arch/powerpc/include/asm/dma-mapping.h | 18 +++++++++---------
arch/powerpc/include/asm/pci.h | 4 ++--
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-iommu.c | 2 +-
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 +++---
arch/powerpc/kernel/vio.c | 1 +
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 ++--
arch/sparc/include/asm/dma-mapping.h | 8 ++++----
arch/sparc/kernel/iommu.c | 4 ++--
arch/sparc/kernel/ioport.c | 6 +++---
arch/sparc/kernel/pci_sun4v.c | 2 +-
arch/x86/include/asm/device.h | 2 +-
arch/x86/include/asm/dma-mapping.h | 10 +++++-----
arch/x86/include/asm/iommu.h | 2 +-
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/pci-calgary_64.c | 2 +-
arch/x86/kernel/pci-dma.c | 4 ++--
arch/x86/kernel/pci-gart_64.c | 2 +-
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 2 +-
drivers/pci/intel-iommu.c | 2 +-
include/asm-generic/dma-mapping-common.h | 24 ++++++++++++------------
35 files changed, 77 insertions(+), 76 deletions(-)

diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index e4a80d8..11a7ea1 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -17,7 +17,7 @@
#include <linux/swiotlb.h>
#include <asm/machvec.h>

-extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;
+extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;

/* swiotlb declarations & definitions: */
extern int swiotlb_late_init_with_default_size (size_t size);
@@ -33,7 +33,7 @@ static inline int use_swiotlb(struct device *dev)
!sba_dma_ops.dma_supported(dev, *dev->dma_mask);
}

-struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
+const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
{
if (use_swiotlb(dev))
return &swiotlb_dma_ops;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 674a837..a4465c6 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2077,7 +2077,7 @@ static struct acpi_driver acpi_sba_ioc_driver = {
},
};

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static int __init
sba_init(void)
@@ -2191,7 +2191,7 @@ sba_page_override(char *str)

__setup("sbapagesize=",sba_page_override);

-struct dma_map_ops sba_dma_ops = {
+const struct dma_map_ops sba_dma_ops = {
.alloc_coherent = sba_alloc_coherent,
.free_coherent = sba_free_coherent,
.map_page = sba_map_page,
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 8d3c79c..71b3af6 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -12,7 +12,7 @@

#define ARCH_HAS_DMA_GET_REQUIRED_MASK

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;
extern struct ia64_machine_vector ia64_mv;
extern void set_iommu_machvec(void);

@@ -24,7 +24,7 @@ extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *daddr, gfp_t gfp)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
void *caddr;

caddr = ops->alloc_coherent(dev, size, daddr, gfp);
@@ -35,7 +35,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *caddr, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
debug_dma_free_coherent(dev, size, caddr, daddr);
ops->free_coherent(dev, size, caddr, daddr);
}
@@ -49,13 +49,13 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->mapping_error(dev, daddr);
}

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->dma_supported(dev, mask);
}

diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299..9ad4279 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -45,7 +45,7 @@ typedef void ia64_mv_kernel_launch_event_t(void);
/* DMA-mapping interface: */
typedef void ia64_mv_dma_init (void);
typedef u64 ia64_mv_dma_get_required_mask (struct device *);
-typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
+typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);

/*
* WARNING: The legacy I/O space is _architected_. Platforms are
@@ -251,7 +251,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
# endif /* CONFIG_IA64_GENERIC */

extern void swiotlb_dma_init(void);
-extern struct dma_map_ops *dma_get_ops(struct device *);
+extern const struct dma_map_ops *dma_get_ops(struct device *);

/*
* Define default versions so we can extend machvec for new platforms without having
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index f2c1600..969398a 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -3,7 +3,7 @@
/* Set this to 1 if there is a HW IOMMU in the system */
int iommu_detected __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
@@ -16,7 +16,7 @@ static int __init dma_init(void)
}
fs_initcall(dma_init);

-struct dma_map_ops *dma_get_ops(struct device *dev)
+const struct dma_map_ops *dma_get_ops(struct device *dev)
{
return dma_ops;
}
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index f6b1ff0..ccacc2f 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -43,7 +43,7 @@ struct device fallback_dev = {
.dma_mask = &fallback_dev.coherent_dma_mask,
};

-extern struct dma_map_ops intel_dma_ops;
+extern const struct dma_map_ops intel_dma_ops;

static int __init pci_iommu_init(void)
{
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 285aae8..61dbab6 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -21,7 +21,7 @@ static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
}

-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = ia64_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
.map_page = swiotlb_map_page,
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 98b6849..8046766 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -464,7 +464,7 @@ int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
return ret;
}

-static struct dma_map_ops sn_dma_ops = {
+static const struct dma_map_ops sn_dma_ops = {
.alloc_coherent = sn_dma_alloc_coherent,
.free_coherent = sn_dma_free_coherent,
.map_page = sn_dma_map_page,
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 6d94d27..50d4cad 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -14,7 +14,7 @@ struct dev_archdata {
struct device_node *of_node;

/* DMA operations on that device */
- struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;

/*
* When an iommu is in use, dma_data is used as a ptr to the base of the
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index e281dae..f025ef0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -67,11 +67,11 @@ static inline unsigned long device_to_mask(struct device *dev)
* Available generic sets of operations
*/
#ifdef CONFIG_PPC64
-extern struct dma_map_ops dma_iommu_ops;
+extern const struct dma_map_ops dma_iommu_ops;
#endif
-extern struct dma_map_ops dma_direct_ops;
+extern const struct dma_map_ops dma_direct_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
/* We don't handle the NULL dev case for ISA for now. We could
* do it via an out of line call but it is not needed for now. The
@@ -84,7 +84,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
return dev->archdata.dma_ops;
}

-static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
+static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
{
dev->archdata.dma_ops = ops;
}
@@ -118,7 +118,7 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return 0;
@@ -132,7 +132,7 @@ static inline int dma_supported(struct device *dev, u64 mask)

static inline int dma_set_mask(struct device *dev, u64 dma_mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return -EIO;
@@ -147,7 +147,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);
void *cpu_addr;

BUG_ON(!dma_ops);
@@ -162,7 +162,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -173,7 +173,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (dma_ops->mapping_error)
return dma_ops->mapping_error(dev, dma_addr);
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..4030822 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -65,8 +65,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
}

#ifdef CONFIG_PCI
-extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
-extern struct dma_map_ops *get_pci_dma_ops(void);
+extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
+extern const struct dma_map_ops *get_pci_dma_ops(void);
#else /* CONFIG_PCI */
#define set_pci_dma_ops(d)
#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 8979d4c..d2fd0d3 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@

#include <linux/swiotlb.h>

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 37771a5..37a9fc2 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
return 1;
}

-struct dma_map_ops dma_iommu_ops = {
+const struct dma_map_ops dma_iommu_ops = {
.alloc_coherent = dma_iommu_alloc_coherent,
.free_coherent = dma_iommu_free_coherent,
.map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e96cbbd..bdd6d41 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
* map_page, and unmap_page on highmem, use normal dma_ops
* for everything else.
*/
-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 6215062..ebea59c 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -134,7 +134,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
}
#endif

-struct dma_map_ops dma_direct_ops = {
+const struct dma_map_ops dma_direct_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = dma_direct_map_sg,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index a4c8b38..1b09ad9 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
return 1;
}

-static struct dma_map_ops ibmebus_dma_ops = {
+static const struct dma_map_ops ibmebus_dma_ops = {
.alloc_coherent = ibmebus_alloc_coherent,
.free_coherent = ibmebus_free_coherent,
.map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index e8dfdbd..8583013 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
unsigned int ppc_pci_flags = 0;


-static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
+static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops;

-void set_pci_dma_ops(struct dma_map_ops *dma_ops)
+void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
{
pci_dma_ops = dma_ops;
}

-struct dma_map_ops *get_pci_dma_ops(void)
+const struct dma_map_ops *get_pci_dma_ops(void)
{
return pci_dma_ops;
}
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 77f6421..f8ee67f 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,6 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
vio_cmo_dealloc(viodev, alloc_size);
}

+/* cannot be const */
struct dma_map_ops vio_dma_mapping_ops = {
.alloc_coherent = vio_dma_iommu_alloc_coherent,
.free_coherent = vio_dma_iommu_free_coherent,
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ca5bfdf..1602e09 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)

static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);

-struct dma_map_ops dma_iommu_fixed_ops = {
+const struct dma_map_ops dma_iommu_fixed_ops = {
.alloc_coherent = dma_fixed_alloc_coherent,
.free_coherent = dma_fixed_free_coherent,
.map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index e34b305..20e48ec 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
return mask >= DMA_BIT_MASK(32);
}

-static struct dma_map_ops ps3_sb_dma_ops = {
+static const struct dma_map_ops ps3_sb_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_map_ops ps3_sb_dma_ops = {
.unmap_page = ps3_unmap_page,
};

-static struct dma_map_ops ps3_ioc0_dma_ops = {
+static const struct dma_map_ops ps3_ioc0_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_ioc0_map_sg,
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5a8c308..fb7c253 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -14,10 +14,10 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask);
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#define dma_is_consistent(d, h) (1)

-extern struct dma_map_ops *dma_ops, pci32_dma_ops;
+extern struct const dma_map_ops *dma_ops, pci32_dma_ops;
extern struct bus_type pci_bus_type;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
if (dev->bus == &pci_bus_type)
@@ -31,7 +31,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *cpu_addr;

cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
@@ -42,7 +42,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
ops->free_coherent(dev, size, cpu_addr, dma_handle);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 7690cc2..ece64c9 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4u_dma_ops = {
+static const struct dma_map_ops sun4u_dma_ops = {
.alloc_coherent = dma_4u_alloc_coherent,
.free_coherent = dma_4u_free_coherent,
.map_page = dma_4u_map_page,
@@ -837,7 +837,7 @@ static struct dma_map_ops sun4u_dma_ops = {
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
};

-struct dma_map_ops *dma_ops = &sun4u_dma_ops;
+const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
EXPORT_SYMBOL(dma_ops);

extern int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9f61fd8..bd048db 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -392,7 +392,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
BUG();
}

-struct dma_map_ops sbus_dma_ops = {
+const struct dma_map_ops sbus_dma_ops = {
.alloc_coherent = sbus_alloc_coherent,
.free_coherent = sbus_free_coherent,
.map_page = sbus_map_page,
@@ -403,7 +403,7 @@ struct dma_map_ops sbus_dma_ops = {
.sync_sg_for_device = sbus_sync_sg_for_device,
};

-struct dma_map_ops *dma_ops = &sbus_dma_ops;
+const struct dma_map_ops *dma_ops = &sbus_dma_ops;
EXPORT_SYMBOL(dma_ops);

static int __init sparc_register_ioport(void)
@@ -640,7 +640,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist *
}
}

-struct dma_map_ops pci32_dma_ops = {
+const struct dma_map_ops pci32_dma_ops = {
.alloc_coherent = pci32_alloc_coherent,
.free_coherent = pci32_free_coherent,
.map_page = pci32_map_page,
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 23c33ff..d137fbd 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -525,7 +525,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4v_dma_ops = {
+static const struct dma_map_ops sun4v_dma_ops = {
.alloc_coherent = dma_4v_alloc_coherent,
.free_coherent = dma_4v_free_coherent,
.map_page = dma_4v_map_page,
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index cee34e9..a7c3fa2 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -6,7 +6,7 @@ struct dev_archdata {
void *acpi_handle;
#endif
#ifdef CONFIG_X86_64
-struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;
#endif
#ifdef CONFIG_DMAR
void *iommu; /* hook for IOMMU specific extension */
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 6a25d5d..786b202 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@ extern int iommu_merge;
extern struct device x86_dma_fallback_dev;
extern int panic_on_overflow;

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#ifdef CONFIG_X86_32
return dma_ops;
@@ -44,7 +44,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
/* Make sure we keep the same behaviour */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

@@ -122,7 +122,7 @@ static inline void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *memory;

gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
@@ -149,7 +149,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fd6d21b..8b13915 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -3,7 +3,7 @@

extern void pci_iommu_shutdown(void);
extern void no_iommu_init(void);
-extern struct dma_map_ops nommu_dma_ops;
+extern const struct dma_map_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;
extern int iommu_pass_through;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0285521..c3dc83a 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2069,7 +2069,7 @@ static void prealloc_protection_domains(void)
}
}

-static struct dma_map_ops amd_iommu_dma_ops = {
+static const struct dma_map_ops amd_iommu_dma_ops = {
.alloc_coherent = alloc_coherent,
.free_coherent = free_coherent,
.map_page = map_page,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 971a3be..071558a 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -470,7 +470,7 @@ static void calgary_free_coherent(struct device *dev, size_t size,
free_pages((unsigned long)vaddr, get_order(size));
}

-static struct dma_map_ops calgary_dma_ops = {
+static const struct dma_map_ops calgary_dma_ops = {
.alloc_coherent = calgary_alloc_coherent,
.free_coherent = calgary_free_coherent,
.map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a6e804d..e318f5a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -14,7 +14,7 @@

static int forbid_dac __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

static int iommu_sac_force __read_mostly;
@@ -243,7 +243,7 @@ early_param("iommu", iommu_setup);

int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index a7f1b64..24505d3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -679,7 +679,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
return -1;
}

-static struct dma_map_ops gart_dma_ops = {
+static const struct dma_map_ops gart_dma_ops = {
.map_sg = gart_map_sg,
.unmap_sg = gart_unmap_sg,
.map_page = gart_map_page,
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index a3933d4..c898869 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -94,7 +94,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
flush_write_buffers();
}

-struct dma_map_ops nommu_dma_ops = {
+const struct dma_map_ops nommu_dma_ops = {
.alloc_coherent = dma_generic_alloc_coherent,
.free_coherent = nommu_free_coherent,
.map_sg = nommu_map_sg,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index aaa6b78..4de1881 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -25,7 +25,7 @@ static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
return swiotlb_alloc_coherent(hwdev, size, dma_handle, flags);
}

-static struct dma_map_ops swiotlb_dma_ops = {
+static const struct dma_map_ops swiotlb_dma_ops = {
.mapping_error = swiotlb_dma_mapping_error,
.alloc_coherent = x86_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1840a05..b4ece9f 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2937,7 +2937,7 @@ static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
return !dma_addr;
}

-struct dma_map_ops intel_dma_ops = {
+const struct dma_map_ops intel_dma_ops = {
.alloc_coherent = intel_alloc_coherent,
.free_coherent = intel_free_coherent,
.map_sg = intel_map_sg,
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index e694263..9ffa925 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -11,7 +11,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(ptr, size);
@@ -30,7 +30,7 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -42,7 +42,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
int i, ents;
struct scatterlist *s;

@@ -59,7 +59,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
debug_dma_unmap_sg(dev, sg, nents, dir);
@@ -71,7 +71,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
size_t offset, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(page_address(page) + offset, size);
@@ -85,7 +85,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
size_t size, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -97,7 +97,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_cpu)
@@ -109,7 +109,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_device)
@@ -123,7 +123,7 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_cpu) {
@@ -140,7 +140,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_device) {
@@ -155,7 +155,7 @@ static inline void
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_cpu)
@@ -167,7 +167,7 @@ static inline void
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_device)

2009-12-04 22:14:28

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_mac_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 3 ++-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 3 ++-
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 2 +-
6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..16ffb11 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const */
struct e1000_mac_operations *func = &mac->ops;
u32 swsm = 0;
u32 swsm2 = 0;
@@ -1656,7 +1657,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
temp = er32(ICRXDMTC);
}

-static struct e1000_mac_operations e82571_mac_ops = {
+static const struct e1000_mac_operations e82571_mac_ops = {
/* .check_mng_mode: mac type dependent */
/* .check_for_link: media type dependent */
.id_led_init = e1000e_id_led_init,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..933f5da 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -375,7 +375,7 @@ struct e1000_info {
u32 pba;
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..06d47e0 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -207,6 +207,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const */
struct e1000_mac_operations *func = &mac->ops;

/* Set media type */
@@ -1365,7 +1366,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
temp = er32(ICRXDMTC);
}

-static struct e1000_mac_operations es2_mac_ops = {
+static const struct e1000_mac_operations es2_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000e_check_mng_mode_generic,
/* check_for_link dependent on media type */
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..3e0065b 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3451,7 +3451,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
}
}

-static struct e1000_mac_operations ich8_mac_ops = {
+static const struct e1000_mac_operations ich8_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000_check_mng_mode_ich8lan,
.check_for_link = e1000_check_for_copper_link_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..3d5794f 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1400,7 +1400,7 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
wr32(E1000_VT_CTL, vt_ctl);
}

-static struct e1000_mac_operations e1000_mac_ops_82575 = {
+static const struct e1000_mac_operations e1000_mac_ops_82575 = {
.reset_hw = igb_reset_hw_82575,
.init_hw = igb_init_hw_82575,
.check_for_link = igb_check_for_link_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..d58b7e5 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -310,7 +310,7 @@ struct e1000_nvm_operations {

struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

2009-12-04 22:15:46

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 07/31] Constify struct e1000_nvm_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_nvm_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 2 +-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/hw.h | 16 ++++++++--------
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 12 ++++++------
7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..2a2355f 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1725,7 +1725,7 @@ static struct e1000_phy_operations e82_phy_ops_bm = {
.cfg_on_link_up = NULL,
};

-static struct e1000_nvm_operations e82571_nvm_ops = {
+static const struct e1000_nvm_operations e82571_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_82571,
.read_nvm = e1000e_read_nvm_eerd,
.release_nvm = e1000_release_nvm_82571,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..bcdcfb1 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -377,7 +377,7 @@ struct e1000_info {
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

/* hardware capability, feature, and workaround flags */
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..a980900 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1400,7 +1400,7 @@ static struct e1000_phy_operations es2_phy_ops = {
.cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
};

-static struct e1000_nvm_operations es2_nvm_ops = {
+static const struct e1000_nvm_operations es2_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_80003es2lan,
.read_nvm = e1000e_read_nvm_eerd,
.release_nvm = e1000_release_nvm_80003es2lan,
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index aaea41e..f7f181f 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -776,13 +776,13 @@ struct e1000_phy_operations {

/* Function pointers for the NVM. */
struct e1000_nvm_operations {
- s32 (*acquire_nvm)(struct e1000_hw *);
- s32 (*read_nvm)(struct e1000_hw *, u16, u16, u16 *);
- void (*release_nvm)(struct e1000_hw *);
- s32 (*update_nvm)(struct e1000_hw *);
- s32 (*valid_led_default)(struct e1000_hw *, u16 *);
- s32 (*validate_nvm)(struct e1000_hw *);
- s32 (*write_nvm)(struct e1000_hw *, u16, u16, u16 *);
+ s32 (* const acquire_nvm)(struct e1000_hw *);
+ s32 (* const read_nvm)(struct e1000_hw *, u16, u16, u16 *);
+ void (* const release_nvm)(struct e1000_hw *);
+ s32 (* const update_nvm)(struct e1000_hw *);
+ s32 (* const valid_led_default)(struct e1000_hw *, u16 *);
+ s32 (* const validate_nvm)(struct e1000_hw *);
+ s32 (* const write_nvm)(struct e1000_hw *, u16, u16, u16 *);
};

struct e1000_mac_info {
@@ -856,7 +856,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
- struct e1000_nvm_operations ops;
+ const struct e1000_nvm_operations ops;

enum e1000_nvm_type type;
enum e1000_nvm_override override;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..8835afa 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3485,7 +3485,7 @@ static struct e1000_phy_operations ich8_phy_ops = {
.write_phy_reg = e1000e_write_phy_reg_igp,
};

-static struct e1000_nvm_operations ich8_nvm_ops = {
+static const struct e1000_nvm_operations ich8_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_ich8lan,
.read_nvm = e1000_read_nvm_ich8lan,
.release_nvm = e1000_release_nvm_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..f62d4e1 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1415,7 +1415,7 @@ static struct e1000_phy_operations e1000_phy_ops_82575 = {
.release = igb_release_phy_82575,
};

-static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
+static const struct e1000_nvm_operations e1000_nvm_ops_82575 = {
.acquire = igb_acquire_nvm_82575,
.read = igb_read_nvm_eerd,
.release = igb_release_nvm_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..c31e6b2 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -302,17 +302,17 @@ struct e1000_phy_operations {
};

struct e1000_nvm_operations {
- s32 (*acquire)(struct e1000_hw *);
- s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
- void (*release)(struct e1000_hw *);
- s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
+ s32 (* const acquire)(struct e1000_hw *);
+ s32 (* const read)(struct e1000_hw *, u16, u16, u16 *);
+ void (* const release)(struct e1000_hw *);
+ s32 (* const write)(struct e1000_hw *, u16, u16, u16 *);
};

struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

extern const struct e1000_info e1000_82575_info;
@@ -397,7 +397,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
- struct e1000_nvm_operations ops;
+ const struct e1000_nvm_operations ops;

enum e1000_nvm_type type;
enum e1000_nvm_override override;

2009-12-04 22:17:26

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 08/31] Constify struct e1000_phy_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_phy_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 6 +++---
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..9457254 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1674,7 +1674,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations e82_phy_ops_igp = {
+static const struct e1000_phy_operations e82_phy_ops_igp = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = NULL,
@@ -1691,7 +1691,7 @@ static struct e1000_phy_operations e82_phy_ops_igp = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_m88 = {
+static const struct e1000_phy_operations e82_phy_ops_m88 = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
@@ -1708,7 +1708,7 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_bm = {
+static const struct e1000_phy_operations e82_phy_ops_bm = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..7744c27 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -376,7 +376,7 @@ struct e1000_info {
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..631c037 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1383,7 +1383,7 @@ static struct e1000_mac_operations es2_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations es2_phy_ops = {
+static const struct e1000_phy_operations es2_phy_ops = {
.acquire_phy = e1000_acquire_phy_80003es2lan,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..ca9d830 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3469,7 +3469,7 @@ static struct e1000_mac_operations ich8_mac_ops = {
/* id_led_init dependent on mac type */
};

-static struct e1000_phy_operations ich8_phy_ops = {
+static const struct e1000_phy_operations ich8_phy_ops = {
.acquire_phy = e1000_acquire_swflag_ich8lan,
.check_reset_block = e1000_check_reset_block_ich8lan,
.commit_phy = NULL,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..a3e64ae 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1409,7 +1409,7 @@ static struct e1000_mac_operations e1000_mac_ops_82575 = {
.get_speed_and_duplex = igb_get_speed_and_duplex_copper,
};

-static struct e1000_phy_operations e1000_phy_ops_82575 = {
+static const struct e1000_phy_operations e1000_phy_ops_82575 = {
.acquire = igb_acquire_phy_82575,
.get_cfg_done = igb_get_cfg_done_82575,
.release = igb_release_phy_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..326e0e7 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -311,7 +311,7 @@ struct e1000_nvm_operations {
struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

2009-12-04 22:19:14

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 09/31] Constify struct extent_io_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct extent_io_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
fs/btrfs/disk-io.c | 4 ++--
fs/btrfs/extent_io.h | 30 +++++++++++++++---------------
fs/btrfs/inode.c | 4 ++--
3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 02b6afb..6c78215 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -39,7 +39,7 @@
#include "tree-log.h"
#include "free-space-cache.h"

-static struct extent_io_ops btree_extent_io_ops;
+static const struct extent_io_ops btree_extent_io_ops;
static void end_workqueue_fn(struct btrfs_work *work);
static void free_fs_root(struct btrfs_root *root);

@@ -2585,7 +2585,7 @@ out:
return 0;
}

-static struct extent_io_ops btree_extent_io_ops = {
+static const struct extent_io_ops btree_extent_io_ops = {
.write_cache_pages_lock_hook = btree_lock_page_hook,
.readpage_end_io_hook = btree_readpage_end_io_hook,
.submit_bio_hook = btree_submit_bio_hook,
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 36de250..7ec75c7 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -49,36 +49,36 @@ typedef int (extent_submit_bio_hook_t)(struct inode *inode, int rw,
struct bio *bio, int mirror_num,
unsigned long bio_flags);
struct extent_io_ops {
- int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
+ int (* const fill_delalloc)(struct inode *inode, struct page *locked_page,
u64 start, u64 end, int *page_started,
unsigned long *nr_written);
- int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
- int (*writepage_io_hook)(struct page *page, u64 start, u64 end);
+ int (* const writepage_start_hook)(struct page *page, u64 start, u64 end);
+ int (* const writepage_io_hook)(struct page *page, u64 start, u64 end);
extent_submit_bio_hook_t *submit_bio_hook;
- int (*merge_bio_hook)(struct page *page, unsigned long offset,
+ int (* const merge_bio_hook)(struct page *page, unsigned long offset,
size_t size, struct bio *bio,
unsigned long bio_flags);
- int (*readpage_io_hook)(struct page *page, u64 start, u64 end);
- int (*readpage_io_failed_hook)(struct bio *bio, struct page *page,
+ int (* const readpage_io_hook)(struct page *page, u64 start, u64 end);
+ int (* const readpage_io_failed_hook)(struct bio *bio, struct page *page,
u64 start, u64 end,
struct extent_state *state);
- int (*writepage_io_failed_hook)(struct bio *bio, struct page *page,
+ int (* const writepage_io_failed_hook)(struct bio *bio, struct page *page,
u64 start, u64 end,
struct extent_state *state);
- int (*readpage_end_io_hook)(struct page *page, u64 start, u64 end,
+ int (* const readpage_end_io_hook)(struct page *page, u64 start, u64 end,
struct extent_state *state);
- int (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
+ int (* const writepage_end_io_hook)(struct page *page, u64 start, u64 end,
struct extent_state *state, int uptodate);
- int (*set_bit_hook)(struct inode *inode, u64 start, u64 end,
+ int (* const set_bit_hook)(struct inode *inode, u64 start, u64 end,
unsigned long old, unsigned long bits);
- int (*clear_bit_hook)(struct inode *inode, struct extent_state *state,
+ int (* const clear_bit_hook)(struct inode *inode, struct extent_state *state,
unsigned long bits);
- int (*merge_extent_hook)(struct inode *inode,
+ int (* const merge_extent_hook)(struct inode *inode,
struct extent_state *new,
struct extent_state *other);
- int (*split_extent_hook)(struct inode *inode,
+ int (* const split_extent_hook)(struct inode *inode,
struct extent_state *orig, u64 split);
- int (*write_cache_pages_lock_hook)(struct page *page);
+ int (* const write_cache_pages_lock_hook)(struct page *page);
};

struct extent_io_tree {
@@ -88,7 +88,7 @@ struct extent_io_tree {
u64 dirty_bytes;
spinlock_t lock;
spinlock_t buffer_lock;
- struct extent_io_ops *ops;
+ const struct extent_io_ops *ops;
};

struct extent_state {
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b3ad168..3453cba 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -63,7 +63,7 @@ static const struct inode_operations btrfs_file_inode_operations;
static const struct address_space_operations btrfs_aops;
static const struct address_space_operations btrfs_symlink_aops;
static const struct file_operations btrfs_dir_file_operations;
-static struct extent_io_ops btrfs_extent_io_ops;
+static const struct extent_io_ops btrfs_extent_io_ops;

static struct kmem_cache *btrfs_inode_cachep;
struct kmem_cache *btrfs_trans_handle_cachep;
@@ -5854,7 +5854,7 @@ static const struct file_operations btrfs_dir_file_operations = {
.fsync = btrfs_sync_file,
};

-static struct extent_io_ops btrfs_extent_io_ops = {
+static const struct extent_io_ops btrfs_extent_io_ops = {
.fill_delalloc = run_delalloc_range,
.submit_bio_hook = btrfs_submit_bio_hook,
.merge_bio_hook = btrfs_merge_bio_hook,

2009-12-04 22:22:28

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 10/31] Constify struct file_lock_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct file_lock_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
include/linux/fs.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2620a8c..5c621a0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1027,8 +1027,8 @@ static inline int file_check_writeable(struct file *filp)
typedef struct files_struct *fl_owner_t;

struct file_lock_operations {
- void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
- void (*fl_release_private)(struct file_lock *);
+ void (* const fl_copy_lock)(struct file_lock *, struct file_lock *);
+ void (* const fl_release_private)(struct file_lock *);
};

struct lock_manager_operations {

2009-12-04 22:24:19

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct file_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/battery.c | 2 +-
drivers/char/pty.c | 16 +++++++++---
drivers/char/tty_io.c | 28 ++++-----------------
drivers/media/dvb/dvb-core/dvbdev.c | 1 +
drivers/net/wireless/b43/debugfs.c | 2 +-
drivers/net/wireless/b43legacy/debugfs.c | 2 +-
drivers/net/wireless/libertas/debugfs.c | 2 +-
drivers/staging/b3dfg/b3dfg.c | 2 +-
drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
drivers/staging/dream/qdsp5/audio_in.c | 4 +-
drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
drivers/staging/dream/qdsp5/audio_out.c | 4 +-
drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
drivers/staging/dream/qdsp5/snd.c | 2 +-
drivers/staging/dream/smd/smd_qmi.c | 2 +-
drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 +-
drivers/staging/panel/panel.c | 4 +-
drivers/staging/poch/poch.c | 2 +-
drivers/staging/sep/sep_driver.c | 2 +-
drivers/staging/vme/devices/vme_user.c | 2 +-
fs/fuse/cuse.c | 20 +++++++++------
fs/fuse/dev.c | 8 +++---
fs/fuse/fuse_i.h | 10 ++++++++
include/linux/tty.h | 14 ++++++++++-
include/net/tcp.h | 1 +
include/net/udp.h | 1 +
kernel/trace/trace_events.c | 2 +
virt/kvm/kvm_main.c | 3 ++
31 files changed, 89 insertions(+), 63 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3f4602b..2e41d36 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
}

static struct battery_file {
- struct file_operations ops;
+ const struct file_operations ops;
mode_t mode;
const char *name;
} acpi_battery_file[] = {
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 62f282e..d39c67b 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
return ret;
}

-static struct file_operations ptmx_fops;
+static const struct file_operations ptmx_fops = {
+ .llseek = no_llseek,
+ .read = tty_read,
+ .write = tty_write,
+ .poll = tty_poll,
+ .unlocked_ioctl = tty_ioctl,
+ .compat_ioctl = tty_compat_ioctl,
+ .open = ptmx_open,
+ .release = tty_release,
+ .fasync = tty_fasync,
+};
+

static void __init unix98_pty_init(void)
{
@@ -736,9 +747,6 @@ static void __init unix98_pty_init(void)
register_sysctl_table(pty_root_table);

/* Now create the /dev/ptmx special device */
- tty_default_fops(&ptmx_fops);
- ptmx_fops.open = ptmx_open;
-
cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 59499ee..9459c2d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -136,21 +136,10 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
DEFINE_MUTEX(tty_mutex);
EXPORT_SYMBOL(tty_mutex);

-static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
ssize_t redirected_tty_write(struct file *, const char __user *,
size_t, loff_t *);
-static unsigned int tty_poll(struct file *, poll_table *);
static int tty_open(struct inode *, struct file *);
-static int tty_release(struct inode *, struct file *);
long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-static long tty_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg);
-#else
-#define tty_compat_ioctl NULL
-#endif
-static int tty_fasync(int fd, struct file *filp, int on);
static void release_tty(struct tty_struct *tty, int idx);
static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
@@ -870,7 +859,7 @@ EXPORT_SYMBOL(start_tty);
* read calls may be outstanding in parallel.
*/

-static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
+ssize_t tty_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
int i;
@@ -1045,7 +1034,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
* write method will not be invoked in parallel for each device.
*/

-static ssize_t tty_write(struct file *file, const char __user *buf,
+ssize_t tty_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct tty_struct *tty;
@@ -1865,7 +1854,7 @@ static int tty_open(struct inode *inode, struct file *filp)
* Takes bkl. See tty_release_dev
*/

-static int tty_release(struct inode *inode, struct file *filp)
+int tty_release(struct inode *inode, struct file *filp)
{
lock_kernel();
tty_release_dev(filp);
@@ -1885,7 +1874,7 @@ static int tty_release(struct inode *inode, struct file *filp)
* may be re-entered freely by other callers.
*/

-static unsigned int tty_poll(struct file *filp, poll_table *wait)
+unsigned int tty_poll(struct file *filp, poll_table *wait)
{
struct tty_struct *tty;
struct tty_ldisc *ld;
@@ -1902,7 +1891,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
return ret;
}

-static int tty_fasync(int fd, struct file *filp, int on)
+int tty_fasync(int fd, struct file *filp, int on)
{
struct tty_struct *tty;
unsigned long flags;
@@ -2579,7 +2568,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}

#ifdef CONFIG_COMPAT
-static long tty_compat_ioctl(struct file *file, unsigned int cmd,
+long tty_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct inode *inode = file->f_dentry->d_inode;
@@ -3046,11 +3035,6 @@ struct tty_struct *get_current_tty(void)
}
EXPORT_SYMBOL_GPL(get_current_tty);

-void tty_default_fops(struct file_operations *fops)
-{
- *fops = tty_fops;
-}
-
/*
* Initialize the console device. This is called *early*, so
* we can't necessarily depend on lots of kernel help here.
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..3eadb2e 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -191,6 +191,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type)
{
struct dvb_device *dvbdev;
+ /* cannot be const */
struct file_operations *dvbdevfops;
struct device *clsdev;
int minor;
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 80b19a4..dab3a45 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -43,7 +43,7 @@ static struct dentry *rootdir;
struct b43_debugfs_fops {
ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43_dfs_file in struct b43_dfsentry */
size_t file_struct_offset;
};
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 1f85ac5..c99b4b4 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -44,7 +44,7 @@ static struct dentry *rootdir;
struct b43legacy_debugfs_fops {
ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
size_t file_struct_offset;
/* Take wl->irq_lock before calling read/write? */
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 893a55c..7f66a50 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -708,7 +708,7 @@ out_unlock:
struct lbs_debugfs_files {
const char *name;
int perm;
- struct file_operations fops;
+ const struct file_operations fops;
};

static const struct lbs_debugfs_files debugfs_files[] = {
diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index cda26bb..25f3ec6 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -848,7 +848,7 @@ static int b3dfg_mmap(struct file *filp, struct vm_area_struct *vma)
return r;
}

-static struct file_operations b3dfg_fops = {
+static const struct file_operations b3dfg_fops = {
.owner = THIS_MODULE,
.open = b3dfg_open,
.release = b3dfg_release,
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index e55a0db..577b776 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -576,7 +576,7 @@ static struct adsp_device *inode_to_device(struct inode *inode)
static dev_t adsp_devno;
static struct class *adsp_class;

-static struct file_operations adsp_fops = {
+static const struct file_operations adsp_fops = {
.owner = THIS_MODULE,
.open = adsp_open,
.unlocked_ioctl = adsp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index ad2390f..4116ee8 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -1022,7 +1022,7 @@ done:
return rc;
}

-static struct file_operations audio_aac_fops = {
+static const struct file_operations audio_aac_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index cd818a5..870b37b 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -833,7 +833,7 @@ done:
return rc;
}

-static struct file_operations audio_amrnb_fops = {
+static const struct file_operations audio_amrnb_fops = {
.owner = THIS_MODULE,
.open = audamrnb_open,
.release = audamrnb_release,
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index 4b43e18..cedafda 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -805,7 +805,7 @@ dma_fail:
return rc;
}

-static struct file_operations audio_evrc_fops = {
+static const struct file_operations audio_evrc_fops = {
.owner = THIS_MODULE,
.open = audevrc_open,
.release = audevrc_release,
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 3d950a2..9431118 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -913,7 +913,7 @@ static int audpre_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_in_open,
.release = audio_in_release,
@@ -922,7 +922,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_in_ioctl,
};

-static struct file_operations audpre_fops = {
+static const struct file_operations audpre_fops = {
.owner = THIS_MODULE,
.open = audpre_open,
.unlocked_ioctl = audpre_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index b95574f..286c2f4 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -941,7 +941,7 @@ done:
return rc;
}

-static struct file_operations audio_mp3_fops = {
+static const struct file_operations audio_mp3_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index d1adcf6..f8f9833 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -810,7 +810,7 @@ static int audpp_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
@@ -819,7 +819,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_ioctl,
};

-static struct file_operations audpp_fops = {
+static const struct file_operations audpp_fops = {
.owner = THIS_MODULE,
.open = audpp_open,
.unlocked_ioctl = audpp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index f0f50e3..f6b9dbc 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -816,7 +816,7 @@ err:
return rc;
}

-static struct file_operations audio_qcelp_fops = {
+static const struct file_operations audio_qcelp_fops = {
.owner = THIS_MODULE,
.open = audqcelp_open,
.release = audqcelp_release,
diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
index 037d7ff..5469ec3 100644
--- a/drivers/staging/dream/qdsp5/snd.c
+++ b/drivers/staging/dream/qdsp5/snd.c
@@ -242,7 +242,7 @@ err:
return rc;
}

-static struct file_operations snd_fops = {
+static const struct file_operations snd_fops = {
.owner = THIS_MODULE,
.open = snd_open,
.release = snd_release,
diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c
index d4e7d88..0ea632a 100644
--- a/drivers/staging/dream/smd/smd_qmi.c
+++ b/drivers/staging/dream/smd/smd_qmi.c
@@ -793,7 +793,7 @@ static int qmi_release(struct inode *ip, struct file *fp)
return 0;
}

-static struct file_operations qmi_fops = {
+static const struct file_operations qmi_fops = {
.owner = THIS_MODULE,
.read = qmi_read,
.write = qmi_write,
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
index cd3910b..ff053d3 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
@@ -214,7 +214,7 @@ static long rpcrouter_ioctl(struct file *filp, unsigned int cmd,
return rc;
}

-static struct file_operations rpcrouter_server_fops = {
+static const struct file_operations rpcrouter_server_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
@@ -224,7 +224,7 @@ static struct file_operations rpcrouter_server_fops = {
.unlocked_ioctl = rpcrouter_ioctl,
};

-static struct file_operations rpcrouter_router_fops = {
+static const struct file_operations rpcrouter_router_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 4ce399b..225f9bc 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -1305,7 +1305,7 @@ static int lcd_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations lcd_fops = {
+static const struct file_operations lcd_fops = {
.write = lcd_write,
.open = lcd_open,
.release = lcd_release,
@@ -1565,7 +1565,7 @@ static int keypad_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations keypad_fops = {
+static const struct file_operations keypad_fops = {
.read = keypad_read, /* read */
.open = keypad_open, /* open */
.release = keypad_release, /* close */
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index 2eb8e3d..57616a7 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1057,7 +1057,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
return 0;
}

-static struct file_operations poch_fops = {
+static const struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index f890a16..509ece8 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -2603,7 +2603,7 @@ static struct pci_driver sep_pci_driver = {
static dev_t sep_devno;

/* the files operations structure of the driver */
-static struct file_operations sep_file_operations = {
+static const struct file_operations sep_file_operations = {
.owner = THIS_MODULE,
.ioctl = sep_ioctl,
.poll = sep_poll,
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 7891288..8e31300 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -136,7 +136,7 @@ static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
static int __init vme_user_probe(struct device *, int, int);
static int __exit vme_user_remove(struct device *, int, int);

-static struct file_operations vme_user_fops = {
+static const struct file_operations vme_user_fops = {
.open = vme_user_open,
.release = vme_user_release,
.read = vme_user_read,
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index de792dc..40bbb90 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -528,8 +528,18 @@ static int cuse_channel_release(struct inode *inode, struct file *file)
return rc;
}

-static struct file_operations cuse_channel_fops; /* initialized during init */
-
+static const struct file_operations cuse_channel_fops = { /* initialized during init */
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = do_sync_read,
+ .aio_read = fuse_dev_read,
+ .write = do_sync_write,
+ .aio_write = fuse_dev_write,
+ .poll = fuse_dev_poll,
+ .open = cuse_channel_open,
+ .release = cuse_channel_release,
+ .fasync = fuse_dev_fasync,
+};

/**************************************************************************
* Misc stuff and module initializatiion
@@ -575,12 +585,6 @@ static int __init cuse_init(void)
for (i = 0; i < CUSE_CONNTBL_LEN; i++)
INIT_LIST_HEAD(&cuse_conntbl[i]);

- /* inherit and extend fuse_dev_operations */
- cuse_channel_fops = fuse_dev_operations;
- cuse_channel_fops.owner = THIS_MODULE;
- cuse_channel_fops.open = cuse_channel_open;
- cuse_channel_fops.release = cuse_channel_release;
-
cuse_class = class_create(THIS_MODULE, "cuse");
if (IS_ERR(cuse_class))
return PTR_ERR(cuse_class);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 51d9e33..03c8f95 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -745,7 +745,7 @@ __releases(&fc->lock)
* request_end(). Otherwise add it to the processing list, and set
* the 'sent' flag.
*/
-static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -987,7 +987,7 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out,
* it from the list and copy the rest of the buffer to the request.
* The request is finished by calling request_end()
*/
-static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -1084,7 +1084,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
return err;
}

-static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
+unsigned fuse_dev_poll(struct file *file, poll_table *wait)
{
unsigned mask = POLLOUT | POLLWRNORM;
struct fuse_conn *fc = fuse_get_conn(file);
@@ -1210,7 +1210,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
}
EXPORT_SYMBOL_GPL(fuse_dev_release);

-static int fuse_dev_fasync(int fd, struct file *file, int on)
+int fuse_dev_fasync(int fd, struct file *file, int on)
{
struct fuse_conn *fc = fuse_get_conn(file);
if (!fc)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 01cc462..b11fe78 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -521,6 +521,16 @@ extern const struct file_operations fuse_dev_operations;

extern const struct dentry_operations fuse_dentry_operations;

+extern ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern unsigned fuse_dev_poll(struct file *file, poll_table *wait);
+
+extern int fuse_dev_fasync(int fd, struct file *file, int on);
+
/**
* Inode to nodeid comparison.
*/
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f0f43d0..caee8aa 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,6 +13,7 @@
#include <linux/tty_driver.h>
#include <linux/tty_ldisc.h>
#include <linux/mutex.h>
+#include <linux/poll.h>

#include <asm/system.h>

@@ -432,7 +433,6 @@ extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
extern dev_t tty_devnum(struct tty_struct *tty);
extern void proc_clear_tty(struct task_struct *p);
extern struct tty_struct *get_current_tty(void);
-extern void tty_default_fops(struct file_operations *fops);
extern struct tty_struct *alloc_tty_struct(void);
extern void free_tty_struct(struct tty_struct *tty);
extern void initialize_tty_struct(struct tty_struct *tty,
@@ -482,6 +482,18 @@ extern void tty_ldisc_begin(void);
/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
extern void tty_ldisc_enable(struct tty_struct *tty);

+/* tty_io.c */
+extern ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
+extern ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
+extern unsigned int tty_poll(struct file *, poll_table *);
+#ifdef CONFIG_COMPAT
+extern long tty_compat_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg);
+#else
+#define tty_compat_ioctl NULL
+#endif
+extern int tty_release(struct inode *, struct file *);
+extern int tty_fasync(int fd, struct file *filp, int on);

/* n_tty.c */
extern struct tty_ldisc_ops tty_ldisc_N_TTY;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 03a49c7..e689dcf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1414,6 +1414,7 @@ enum tcp_seq_states {
struct tcp_seq_afinfo {
char *name;
sa_family_t family;
+ /* cannot be const */
struct file_operations seq_fops;
struct seq_operations seq_ops;
};
diff --git a/include/net/udp.h b/include/net/udp.h
index f98abd2..2e6c0a3 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -187,6 +187,7 @@ struct udp_seq_afinfo {
char *name;
sa_family_t family;
struct udp_table *udp_table;
+ /* cannot be const */
struct file_operations seq_fops;
struct seq_operations seq_ops;
};
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index d128f65..cfcc06e 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -951,6 +951,8 @@ static LIST_HEAD(ftrace_module_file_list);
* Modules must own their file_operations to keep up with
* reference counting.
*/
+
+/* cannot be const */
struct ftrace_module_file_ops {
struct list_head list;
struct module *mod;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7495ce3..d0a3cc0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1745,6 +1745,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
return 0;
}

+/* cannot be const */
static struct file_operations kvm_vcpu_fops = {
.release = kvm_vcpu_release,
.unlocked_ioctl = kvm_vcpu_ioctl,
@@ -2341,6 +2342,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}

+/* cannot be const */
static struct file_operations kvm_vm_fops = {
.release = kvm_vm_release,
.unlocked_ioctl = kvm_vm_ioctl,
@@ -2428,6 +2430,7 @@ out:
return r;
}

+/* cannot be const */
static struct file_operations kvm_chardev_ops = {
.unlocked_ioctl = kvm_dev_ioctl,
.compat_ioctl = kvm_dev_ioctl,

2009-12-04 22:25:16

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 12/31] Constify struct hv_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct hv_ops with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/char/hvc_beat.c | 2 +-
drivers/char/hvc_console.c | 6 +++---
drivers/char/hvc_console.h | 6 +++---
drivers/char/hvc_iseries.c | 2 +-
drivers/char/hvc_iucv.c | 2 +-
drivers/char/hvc_rtas.c | 2 +-
drivers/char/hvc_udbg.c | 2 +-
drivers/char/hvc_vio.c | 2 +-
drivers/char/hvc_xen.c | 2 +-
drivers/char/virtio_console.c | 1 +
10 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c
index 0afc8b8..6913fc3 100644
--- a/drivers/char/hvc_beat.c
+++ b/drivers/char/hvc_beat.c
@@ -84,7 +84,7 @@ static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt)
return cnt;
}

-static struct hv_ops hvc_beat_get_put_ops = {
+static const struct hv_ops hvc_beat_get_put_ops = {
.get_chars = hvc_beat_get_chars,
.put_chars = hvc_beat_put_chars,
};
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index a632f25..e622e05 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -125,7 +125,7 @@ static struct hvc_struct *hvc_get_by_index(int index)
* console interfaces but can still be used as a tty device. This has to be
* static because kmalloc will not work during early console init.
*/
-static struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
+static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
{[0 ... MAX_NR_HVC_CONSOLES - 1] = -1};

@@ -247,7 +247,7 @@ static void destroy_hvc_struct(struct kref *kref)
* vty adapters do NOT get an hvc_instantiate() callback since they
* appear after early console init.
*/
-int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
+int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
{
struct hvc_struct *hp;

@@ -749,7 +749,7 @@ static const struct tty_operations hvc_ops = {
};

struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data,
- struct hv_ops *ops, int outbuf_size)
+ const struct hv_ops *ops, int outbuf_size)
{
struct hvc_struct *hp;
int i;
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h
index 10950ca..ed176c3 100644
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -55,7 +55,7 @@ struct hvc_struct {
int outbuf_size;
int n_outbuf;
uint32_t vtermno;
- struct hv_ops *ops;
+ const struct hv_ops *ops;
int irq_requested;
int data;
struct winsize ws;
@@ -76,11 +76,11 @@ struct hv_ops {
};

/* Register a vterm and a slot index for use as a console (console_init) */
-extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops);
+extern int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops);

/* register a vterm for hvc tty operation (module_init or hotplug add) */
extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int data,
- struct hv_ops *ops, int outbuf_size);
+ const struct hv_ops *ops, int outbuf_size);
/* remove a vterm from hvc tty operation (module_exit or hotplug remove) */
extern int hvc_remove(struct hvc_struct *hp);

diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c
index 936d05b..fd02426 100644
--- a/drivers/char/hvc_iseries.c
+++ b/drivers/char/hvc_iseries.c
@@ -197,7 +197,7 @@ done:
return sent;
}

-static struct hv_ops hvc_get_put_ops = {
+static const struct hv_ops hvc_get_put_ops = {
.get_chars = get_chars,
.put_chars = put_chars,
.notifier_add = notifier_add_irq,
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c
index b8a5d65..619f7d1 100644
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/char/hvc_iucv.c
@@ -922,7 +922,7 @@ static int hvc_iucv_pm_restore_thaw(struct device *dev)


/* HVC operations */
-static struct hv_ops hvc_iucv_ops = {
+static const struct hv_ops hvc_iucv_ops = {
.get_chars = hvc_iucv_get_chars,
.put_chars = hvc_iucv_put_chars,
.notifier_add = hvc_iucv_notifier_add,
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index 88590d0..61c4a61 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -71,7 +71,7 @@ static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
return i;
}

-static struct hv_ops hvc_rtas_get_put_ops = {
+static const struct hv_ops hvc_rtas_get_put_ops = {
.get_chars = hvc_rtas_read_console,
.put_chars = hvc_rtas_write_console,
};
diff --git a/drivers/char/hvc_udbg.c b/drivers/char/hvc_udbg.c
index bd63ba8..b0957e6 100644
--- a/drivers/char/hvc_udbg.c
+++ b/drivers/char/hvc_udbg.c
@@ -58,7 +58,7 @@ static int hvc_udbg_get(uint32_t vtermno, char *buf, int count)
return i;
}

-static struct hv_ops hvc_udbg_ops = {
+static const struct hv_ops hvc_udbg_ops = {
.get_chars = hvc_udbg_get,
.put_chars = hvc_udbg_put,
};
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
index 10be343..27370e9 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/char/hvc_vio.c
@@ -77,7 +77,7 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
return got;
}

-static struct hv_ops hvc_get_put_ops = {
+static const struct hv_ops hvc_get_put_ops = {
.get_chars = filtered_get_chars,
.put_chars = hvc_put_chars,
.notifier_add = notifier_add_irq,
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index a6ee32b..94f8c26 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -120,7 +120,7 @@ static int read_console(uint32_t vtermno, char *buf, int len)
return recv;
}

-static struct hv_ops hvc_ops = {
+static const struct hv_ops hvc_ops = {
.get_chars = read_console,
.put_chars = write_console,
.notifier_add = notifier_add_irq,
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index a035ae3..cc50600 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -44,6 +44,7 @@ static unsigned int in_len;
static char *in, *inbuf;

/* The operations for our console. */
+/* cannot be const */
static struct hv_ops virtio_cons;

/* The hvc device */

2009-12-04 22:26:50

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 13/31] Constify struct intel_dvo_dev_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct intel_dvo_dev_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/gpu/drm/i915/dvo.h | 16 ++++++++--------
drivers/gpu/drm/i915/dvo_ch7017.c | 2 +-
drivers/gpu/drm/i915/dvo_ch7xxx.c | 2 +-
drivers/gpu/drm/i915/dvo_ivch.c | 2 +-
drivers/gpu/drm/i915/dvo_sil164.c | 2 +-
drivers/gpu/drm/i915/dvo_tfp410.c | 2 +-
6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/dvo.h b/drivers/gpu/drm/i915/dvo.h
index 288fc50..c609205 100644
--- a/drivers/gpu/drm/i915/dvo.h
+++ b/drivers/gpu/drm/i915/dvo.h
@@ -135,23 +135,23 @@ struct intel_dvo_dev_ops {
*
* \return singly-linked list of modes or NULL if no modes found.
*/
- struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo);
+ struct drm_display_mode *(* const get_modes)(struct intel_dvo_device *dvo);

/**
* Clean up driver-specific bits of the output
*/
- void (*destroy) (struct intel_dvo_device *dvo);
+ void (* const destroy) (struct intel_dvo_device *dvo);

/**
* Debugging hook to dump device registers to log file
*/
- void (*dump_regs)(struct intel_dvo_device *dvo);
+ void (* const dump_regs)(struct intel_dvo_device *dvo);
};

-extern struct intel_dvo_dev_ops sil164_ops;
-extern struct intel_dvo_dev_ops ch7xxx_ops;
-extern struct intel_dvo_dev_ops ivch_ops;
-extern struct intel_dvo_dev_ops tfp410_ops;
-extern struct intel_dvo_dev_ops ch7017_ops;
+extern const struct intel_dvo_dev_ops sil164_ops;
+extern const struct intel_dvo_dev_ops ch7xxx_ops;
+extern const struct intel_dvo_dev_ops ivch_ops;
+extern const struct intel_dvo_dev_ops tfp410_ops;
+extern const struct intel_dvo_dev_ops ch7017_ops;

#endif /* _INTEL_DVO_H */
diff --git a/drivers/gpu/drm/i915/dvo_ch7017.c b/drivers/gpu/drm/i915/dvo_ch7017.c
index 621815b..499d82e 100644
--- a/drivers/gpu/drm/i915/dvo_ch7017.c
+++ b/drivers/gpu/drm/i915/dvo_ch7017.c
@@ -443,7 +443,7 @@ static void ch7017_destroy(struct intel_dvo_device *dvo)
}
}

-struct intel_dvo_dev_ops ch7017_ops = {
+const struct intel_dvo_dev_ops ch7017_ops = {
.init = ch7017_init,
.detect = ch7017_detect,
.mode_valid = ch7017_mode_valid,
diff --git a/drivers/gpu/drm/i915/dvo_ch7xxx.c b/drivers/gpu/drm/i915/dvo_ch7xxx.c
index a9b8962..ac769ba 100644
--- a/drivers/gpu/drm/i915/dvo_ch7xxx.c
+++ b/drivers/gpu/drm/i915/dvo_ch7xxx.c
@@ -356,7 +356,7 @@ static void ch7xxx_destroy(struct intel_dvo_device *dvo)
}
}

-struct intel_dvo_dev_ops ch7xxx_ops = {
+const struct intel_dvo_dev_ops ch7xxx_ops = {
.init = ch7xxx_init,
.detect = ch7xxx_detect,
.mode_valid = ch7xxx_mode_valid,
diff --git a/drivers/gpu/drm/i915/dvo_ivch.c b/drivers/gpu/drm/i915/dvo_ivch.c
index aa176f9..ed2930c 100644
--- a/drivers/gpu/drm/i915/dvo_ivch.c
+++ b/drivers/gpu/drm/i915/dvo_ivch.c
@@ -430,7 +430,7 @@ static void ivch_destroy(struct intel_dvo_device *dvo)
}
}

-struct intel_dvo_dev_ops ivch_ops= {
+const struct intel_dvo_dev_ops ivch_ops= {
.init = ivch_init,
.dpms = ivch_dpms,
.save = ivch_save,
diff --git a/drivers/gpu/drm/i915/dvo_sil164.c b/drivers/gpu/drm/i915/dvo_sil164.c
index e1c1f73..7dbebcf 100644
--- a/drivers/gpu/drm/i915/dvo_sil164.c
+++ b/drivers/gpu/drm/i915/dvo_sil164.c
@@ -290,7 +290,7 @@ static void sil164_destroy(struct intel_dvo_device *dvo)
}
}

-struct intel_dvo_dev_ops sil164_ops = {
+const struct intel_dvo_dev_ops sil164_ops = {
.init = sil164_init,
.detect = sil164_detect,
.mode_valid = sil164_mode_valid,
diff --git a/drivers/gpu/drm/i915/dvo_tfp410.c b/drivers/gpu/drm/i915/dvo_tfp410.c
index 9ecc907..5869da0 100644
--- a/drivers/gpu/drm/i915/dvo_tfp410.c
+++ b/drivers/gpu/drm/i915/dvo_tfp410.c
@@ -323,7 +323,7 @@ static void tfp410_destroy(struct intel_dvo_device *dvo)
}
}

-struct intel_dvo_dev_ops tfp410_ops = {
+const struct intel_dvo_dev_ops tfp410_ops = {
.init = tfp410_init,
.detect = tfp410_detect,
.mode_valid = tfp410_mode_valid,

2009-12-04 22:27:57

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 14/31] Constify struct item_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct item_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
fs/reiserfs/item_ops.c | 12 ++++++------
include/linux/reiserfs_fs.h | 24 ++++++++++++------------
2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index 72cb1cc..d0e3181 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -102,7 +102,7 @@ static void sd_print_vi(struct virtual_item *vi)
vi->vi_index, vi->vi_type, vi->vi_ih);
}

-static struct item_operations stat_data_ops = {
+static const struct item_operations stat_data_ops = {
.bytes_number = sd_bytes_number,
.decrement_key = sd_decrement_key,
.is_left_mergeable = sd_is_left_mergeable,
@@ -196,7 +196,7 @@ static void direct_print_vi(struct virtual_item *vi)
vi->vi_index, vi->vi_type, vi->vi_ih);
}

-static struct item_operations direct_ops = {
+static const struct item_operations direct_ops = {
.bytes_number = direct_bytes_number,
.decrement_key = direct_decrement_key,
.is_left_mergeable = direct_is_left_mergeable,
@@ -341,7 +341,7 @@ static void indirect_print_vi(struct virtual_item *vi)
vi->vi_index, vi->vi_type, vi->vi_ih);
}

-static struct item_operations indirect_ops = {
+static const struct item_operations indirect_ops = {
.bytes_number = indirect_bytes_number,
.decrement_key = indirect_decrement_key,
.is_left_mergeable = indirect_is_left_mergeable,
@@ -628,7 +628,7 @@ static void direntry_print_vi(struct virtual_item *vi)
printk("\n");
}

-static struct item_operations direntry_ops = {
+static const struct item_operations direntry_ops = {
.bytes_number = direntry_bytes_number,
.decrement_key = direntry_decrement_key,
.is_left_mergeable = direntry_is_left_mergeable,
@@ -724,7 +724,7 @@ static void errcatch_print_vi(struct virtual_item *vi)
"Invalid item type observed, run fsck ASAP");
}

-static struct item_operations errcatch_ops = {
+static const struct item_operations errcatch_ops = {
errcatch_bytes_number,
errcatch_decrement_key,
errcatch_is_left_mergeable,
@@ -746,7 +746,7 @@ static struct item_operations errcatch_ops = {
#error Item types must use disk-format assigned values.
#endif

-struct item_operations *item_ops[TYPE_ANY + 1] = {
+const struct item_operations * const item_ops[TYPE_ANY + 1] = {
&stat_data_ops,
&indirect_ops,
&direct_ops,
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index dd31e7b..5a54e06 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1534,24 +1534,24 @@ static inline struct super_block *sb_from_bi(struct buffer_info *bi)
*/

struct item_operations {
- int (*bytes_number) (struct item_head * ih, int block_size);
- void (*decrement_key) (struct cpu_key *);
- int (*is_left_mergeable) (struct reiserfs_key * ih,
+ int (* const bytes_number) (struct item_head * ih, int block_size);
+ void (* const decrement_key) (struct cpu_key *);
+ int (* const is_left_mergeable) (struct reiserfs_key * ih,
unsigned long bsize);
- void (*print_item) (struct item_head *, char *item);
- void (*check_item) (struct item_head *, char *item);
+ void (* const print_item) (struct item_head *, char *item);
+ void (* const check_item) (struct item_head *, char *item);

- int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi,
+ int (* const create_vi) (struct virtual_node * vn, struct virtual_item * vi,
int is_affected, int insert_size);
- int (*check_left) (struct virtual_item * vi, int free,
+ int (* const check_left) (struct virtual_item * vi, int free,
int start_skip, int end_skip);
- int (*check_right) (struct virtual_item * vi, int free);
- int (*part_size) (struct virtual_item * vi, int from, int to);
- int (*unit_num) (struct virtual_item * vi);
- void (*print_vi) (struct virtual_item * vi);
+ int (* const check_right) (struct virtual_item * vi, int free);
+ int (* const part_size) (struct virtual_item * vi, int from, int to);
+ int (* const unit_num) (struct virtual_item * vi);
+ void (* const print_vi) (struct virtual_item * vi);
};

-extern struct item_operations *item_ops[TYPE_ANY + 1];
+extern const struct item_operations * const item_ops[TYPE_ANY + 1];

#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)
#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)

2009-12-04 22:29:12

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 15/31] Constify struct iwl_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct iwl_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-1000.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-5000.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 950267a..80d5fd2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -137,7 +137,7 @@ static struct iwl_lib_ops iwl1000_lib = {
},
};

-static struct iwl_ops iwl1000_ops = {
+static const struct iwl_ops iwl1000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl1000_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index f059b49..fe90e0a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2876,7 +2876,7 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
.build_addsta_hcmd = iwl3945_build_addsta_hcmd,
};

-static struct iwl_ops iwl3945_ops = {
+static const struct iwl_ops iwl3945_ops = {
.ucode = &iwl3945_ucode,
.lib = &iwl3945_lib,
.hcmd = &iwl3945_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 6f703a0..b7c4e48 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2335,7 +2335,7 @@ static struct iwl_lib_ops iwl4965_lib = {
},
};

-static struct iwl_ops iwl4965_ops = {
+static const struct iwl_ops iwl4965_ops = {
.ucode = &iwl4965_ucode,
.lib = &iwl4965_lib,
.hcmd = &iwl4965_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 6e6f516..0ec1f24 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1627,14 +1627,14 @@ static struct iwl_lib_ops iwl5150_lib = {
},
};

-struct iwl_ops iwl5000_ops = {
+const struct iwl_ops iwl5000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl5000_lib,
.hcmd = &iwl5000_hcmd,
.utils = &iwl5000_hcmd_utils,
};

-static struct iwl_ops iwl5150_ops = {
+static const struct iwl_ops iwl5150_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl5150_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 1473452..f07d5e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -146,7 +146,7 @@ static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
.calc_rssi = iwl5000_calc_rssi,
};

-static struct iwl_ops iwl6000_ops = {
+static const struct iwl_ops iwl6000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl6000_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 028d505..0c927e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -67,7 +67,7 @@ struct iwl_tx_queue;

/* shared structures from iwl-5000.c */
extern struct iwl_mod_params iwl50_mod_params;
-extern struct iwl_ops iwl5000_ops;
+extern const struct iwl_ops iwl5000_ops;
extern struct iwl_ucode_ops iwl5000_ucode;
extern struct iwl_lib_ops iwl5000_lib;
extern struct iwl_hcmd_ops iwl5000_hcmd;

2009-12-04 22:30:46

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 16/31] Constify struct kgdb_arch for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct kgdb_arch with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/arm/kernel/kgdb.c | 2 +-
arch/blackfin/kernel/kgdb.c | 2 +-
arch/mips/kernel/kgdb.c | 1 +
arch/powerpc/kernel/kgdb.c | 4 ++--
arch/sh/kernel/kgdb.c | 2 +-
arch/sparc/kernel/kgdb_32.c | 2 +-
arch/sparc/kernel/kgdb_64.c | 2 +-
arch/x86/kernel/kgdb.c | 2 +-
include/linux/kgdb.h | 2 +-
9 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c
index ba8ccfe..2dc34dc 100644
--- a/arch/arm/kernel/kgdb.c
+++ b/arch/arm/kernel/kgdb.c
@@ -190,7 +190,7 @@ void kgdb_arch_exit(void)
* and we handle the normal undef case within the do_undefinstr
* handler.
*/
-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
#ifndef __ARMEB__
.gdb_bpt_instr = {0xfe, 0xde, 0xff, 0xe7}
#else /* ! __ARMEB__ */
diff --git a/arch/blackfin/kernel/kgdb.c b/arch/blackfin/kernel/kgdb.c
index cce79d0..c406c85 100644
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -428,7 +428,7 @@ int kgdb_arch_handle_exception(int vector, int signo,
return -1; /* this means that we do not want to exit from the handler */
}

-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
.gdb_bpt_instr = {0xa1},
#ifdef CONFIG_SMP
.flags = KGDB_HW_BREAKPOINT|KGDB_THR_PROC_SWAP,
diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
index 50c9bb8..efdd5f8 100644
--- a/arch/mips/kernel/kgdb.c
+++ b/arch/mips/kernel/kgdb.c
@@ -245,6 +245,7 @@ int kgdb_arch_handle_exception(int vector, int signo, int err_code,
return -1;
}

+/* cannot be const */
struct kgdb_arch arch_kgdb_ops;

/*
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 641c74b..8339ad7 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -126,7 +126,7 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
if (kgdb_handle_exception(0, SIGTRAP, 0, regs) != 0)
return 0;

- if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
+ if (*(u32 *) (regs->nip) == *(const u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
regs->nip += 4;

return 1;
@@ -353,7 +353,7 @@ int kgdb_arch_handle_exception(int vector, int signo, int err_code,
/*
* Global data
*/
-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
.gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
};

diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c
index 3e532d0..9faa306 100644
--- a/arch/sh/kernel/kgdb.c
+++ b/arch/sh/kernel/kgdb.c
@@ -271,7 +271,7 @@ void kgdb_arch_exit(void)
{
}

-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
/* Breakpoint instruction: trapa #0x3c */
#ifdef CONFIG_CPU_LITTLE_ENDIAN
.gdb_bpt_instr = { 0x3c, 0xc3 },
diff --git a/arch/sparc/kernel/kgdb_32.c b/arch/sparc/kernel/kgdb_32.c
index 04df4ed..55c4b6e 100644
--- a/arch/sparc/kernel/kgdb_32.c
+++ b/arch/sparc/kernel/kgdb_32.c
@@ -158,7 +158,7 @@ void kgdb_arch_exit(void)
{
}

-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
/* Breakpoint instruction: ta 0x7d */
.gdb_bpt_instr = { 0x91, 0xd0, 0x20, 0x7d },
};
diff --git a/arch/sparc/kernel/kgdb_64.c b/arch/sparc/kernel/kgdb_64.c
index f5a0fd4..d886f71 100644
--- a/arch/sparc/kernel/kgdb_64.c
+++ b/arch/sparc/kernel/kgdb_64.c
@@ -180,7 +180,7 @@ void kgdb_arch_exit(void)
{
}

-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
/* Breakpoint instruction: ta 0x72 */
.gdb_bpt_instr = { 0x91, 0xd0, 0x20, 0x72 },
};
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 8d82a77..92e532c 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -573,7 +573,7 @@ unsigned long kgdb_arch_pc(int exception, struct pt_regs *regs)
return instruction_pointer(regs);
}

-struct kgdb_arch arch_kgdb_ops = {
+const struct kgdb_arch arch_kgdb_ops = {
/* Breakpoint instruction: */
.gdb_bpt_instr = { 0xcc },
.flags = KGDB_HW_BREAKPOINT,
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 6adcc29..360613c 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -259,7 +259,7 @@ struct kgdb_io {
void (*post_exception) (void);
};

-extern struct kgdb_arch arch_kgdb_ops;
+extern const struct kgdb_arch arch_kgdb_ops;

extern unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs);

2009-12-04 22:31:59

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 17/31] Constify struct kgdb_io for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct kgdb_io.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/misc/kgdbts.c | 4 ++--
drivers/serial/kgdboc.c | 4 ++--
include/linux/kgdb.h | 18 +++++++++---------
kernel/kgdb.c | 6 +++---
4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index e4ff50b..4cc3f04 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -118,7 +118,7 @@
} while (0)
#define MAX_CONFIG_LEN 40

-static struct kgdb_io kgdbts_io_ops;
+static const struct kgdb_io kgdbts_io_ops;
static char get_buf[BUFMAX];
static int get_buf_cnt;
static char put_buf[BUFMAX];
@@ -1102,7 +1102,7 @@ static void kgdbts_post_exp_handler(void)
module_put(THIS_MODULE);
}

-static struct kgdb_io kgdbts_io_ops = {
+static const struct kgdb_io kgdbts_io_ops = {
.name = "kgdbts",
.read_char = kgdbts_get_char,
.write_char = kgdbts_put_char,
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c
index eadc1ab..2d81457 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/serial/kgdboc.c
@@ -18,7 +18,7 @@

#define MAX_CONFIG_LEN 40

-static struct kgdb_io kgdboc_io_ops;
+static const struct kgdb_io kgdboc_io_ops;

/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
static int configured = -1;
@@ -154,7 +154,7 @@ static void kgdboc_post_exp_handler(void)
module_put(THIS_MODULE);
}

-static struct kgdb_io kgdboc_io_ops = {
+static const struct kgdb_io kgdboc_io_ops = {
.name = "kgdboc",
.read_char = kgdboc_get_char,
.write_char = kgdboc_put_char,
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 6adcc29..ba61222 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -251,20 +251,20 @@ struct kgdb_arch {
*/
struct kgdb_io {
const char *name;
- int (*read_char) (void);
- void (*write_char) (u8);
- void (*flush) (void);
- int (*init) (void);
- void (*pre_exception) (void);
- void (*post_exception) (void);
+ int (* const read_char) (void);
+ void (* const write_char) (u8);
+ void (* const flush) (void);
+ int (* const init) (void);
+ void (* const pre_exception) (void);
+ void (* const post_exception) (void);
};

-extern struct kgdb_arch arch_kgdb_ops;
+extern struct kgdb_arch arch_kgdb_ops;

extern unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs);

-extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
-extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
+extern int kgdb_register_io_module(const struct kgdb_io *local_kgdb_io_ops);
+extern void kgdb_unregister_io_module(const struct kgdb_io *local_kgdb_io_ops);

extern int kgdb_hex2long(char **ptr, unsigned long *long_val);
extern int kgdb_mem2hex(char *mem, char *buf, int count);
diff --git a/kernel/kgdb.c b/kernel/kgdb.c
index 9147a31..f9203e4 100644
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -86,7 +86,7 @@ static int kgdb_io_module_registered;
/* Guard for recursive entry */
static int exception_level;

-static struct kgdb_io *kgdb_io_ops;
+static const struct kgdb_io *kgdb_io_ops;
static DEFINE_SPINLOCK(kgdb_registration_lock);

/* kgdb console driver is loaded */
@@ -1637,7 +1637,7 @@ static void kgdb_initial_breakpoint(void)
*
* Register it with the KGDB core.
*/
-int kgdb_register_io_module(struct kgdb_io *new_kgdb_io_ops)
+int kgdb_register_io_module(const struct kgdb_io *new_kgdb_io_ops)
{
int err;

@@ -1682,7 +1682,7 @@ EXPORT_SYMBOL_GPL(kgdb_register_io_module);
*
* Unregister it with the KGDB core.
*/
-void kgdb_unregister_io_module(struct kgdb_io *old_kgdb_io_ops)
+void kgdb_unregister_io_module(const struct kgdb_io *old_kgdb_io_ops)
{
BUG_ON(kgdb_connected);

2009-12-04 22:34:09

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 18/31] Constify struct kset_uevent_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct kset_uevent_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/base/bus.c | 2 +-
drivers/base/core.c | 2 +-
drivers/base/memory.c | 2 +-
fs/gfs2/sys.c | 2 +-
include/linux/kobject.h | 10 +++++-----
kernel/params.c | 2 +-
lib/kobject.c | 4 ++--
lib/kobject_uevent.c | 2 +-
mm/slub.c | 2 +-
9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 63c143e..c47cd56 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}

-static struct kset_uevent_ops bus_uevent_ops = {
+static const struct kset_uevent_ops bus_uevent_ops = {
.filter = bus_uevent_filter,
};

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6bee6af..4c3b559 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -245,7 +245,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
return retval;
}

-static struct kset_uevent_ops device_uevent_ops = {
+static const struct kset_uevent_ops device_uevent_ops = {
.filter = dev_uevent_filter,
.name = dev_uevent_name,
.uevent = dev_uevent,
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 989429c..2272b00 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uev
return retval;
}

-static struct kset_uevent_ops memory_uevent_ops = {
+static const struct kset_uevent_ops memory_uevent_ops = {
.name = memory_uevent_name,
.uevent = memory_uevent,
};
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 4463297..ca74d56 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -584,7 +584,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
return 0;
}

-static struct kset_uevent_ops gfs2_uevent_ops = {
+static const struct kset_uevent_ops gfs2_uevent_ops = {
.uevent = gfs2_uevent,
};

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 58ae8e0..57a1eaa 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -118,9 +118,9 @@ struct kobj_uevent_env {
};

struct kset_uevent_ops {
- int (*filter)(struct kset *kset, struct kobject *kobj);
- const char *(*name)(struct kset *kset, struct kobject *kobj);
- int (*uevent)(struct kset *kset, struct kobject *kobj,
+ int (* const filter)(struct kset *kset, struct kobject *kobj);
+ const char *(* const name)(struct kset *kset, struct kobject *kobj);
+ int (* const uevent)(struct kset *kset, struct kobject *kobj,
struct kobj_uevent_env *env);
};

@@ -155,14 +155,14 @@ struct kset {
struct list_head list;
spinlock_t list_lock;
struct kobject kobj;
- struct kset_uevent_ops *uevent_ops;
+ const struct kset_uevent_ops *uevent_ops;
};

extern void kset_init(struct kset *kset);
extern int __must_check kset_register(struct kset *kset);
extern void kset_unregister(struct kset *kset);
extern struct kset * __must_check kset_create_and_add(const char *name,
- struct kset_uevent_ops *u,
+ const struct kset_uevent_ops *u,
struct kobject *parent_kobj);

static inline struct kset *to_kset(struct kobject *kobj)
diff --git a/kernel/params.c b/kernel/params.c
index d656c27..e9d197e 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -739,7 +739,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}

-static struct kset_uevent_ops module_uevent_ops = {
+static const struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter,
};

diff --git a/lib/kobject.c b/lib/kobject.c
index b512b74..cecf5a0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {
* If the kset was not able to be created, NULL will be returned.
*/
static struct kset *kset_create(const char *name,
- struct kset_uevent_ops *uevent_ops,
+ const struct kset_uevent_ops *uevent_ops,
struct kobject *parent_kobj)
{
struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,
* If the kset was not able to be created, NULL will be returned.
*/
struct kset *kset_create_and_add(const char *name,
- struct kset_uevent_ops *uevent_ops,
+ const struct kset_uevent_ops *uevent_ops,
struct kobject *parent_kobj)
{
struct kset *kset;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 920a3ca..c9d3a3e 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
const char *subsystem;
struct kobject *top_kobj;
struct kset *kset;
- struct kset_uevent_ops *uevent_ops;
+ const struct kset_uevent_ops *uevent_ops;
u64 seq;
int i = 0;
int retval = 0;
diff --git a/mm/slub.c b/mm/slub.c
index 4996fc7..fb63aca 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}

-static struct kset_uevent_ops slab_uevent_ops = {
+static const struct kset_uevent_ops slab_uevent_ops = {
.filter = uevent_filter,
};

2009-12-04 22:34:30

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 19/31] Constify struct lock_manager_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct lock_manager_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
include/linux/fs.h | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2620a8c..8ed405e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1032,14 +1032,14 @@ struct file_lock_operations {
};

struct lock_manager_operations {
- int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
- void (*fl_notify)(struct file_lock *); /* unblock callback */
- int (*fl_grant)(struct file_lock *, struct file_lock *, int);
- void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
- void (*fl_release_private)(struct file_lock *);
- void (*fl_break)(struct file_lock *);
- int (*fl_mylease)(struct file_lock *, struct file_lock *);
- int (*fl_change)(struct file_lock **, int);
+ int (* const fl_compare_owner)(struct file_lock *, struct file_lock *);
+ void (* const fl_notify)(struct file_lock *); /* unblock callback */
+ int (* const fl_grant)(struct file_lock *, struct file_lock *, int);
+ void (* const fl_copy_lock)(struct file_lock *, struct file_lock *);
+ void (* const fl_release_private)(struct file_lock *);
+ void (* const fl_break)(struct file_lock *);
+ int (* const fl_mylease)(struct file_lock *, struct file_lock *);
+ int (* const fl_change)(struct file_lock **, int);
};

struct lock_manager {

2009-12-04 22:35:33

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 20/31] Constify struct microcode_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct microcode_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/x86/include/asm/microcode.h | 14 +++++++-------
arch/x86/kernel/microcode_amd.c | 4 ++--
arch/x86/kernel/microcode_core.c | 2 +-
arch/x86/kernel/microcode_intel.c | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index ef51b50..514ba37 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -12,13 +12,13 @@ struct device;
enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND };

struct microcode_ops {
- enum ucode_state (*request_microcode_user) (int cpu,
+ enum ucode_state (* const request_microcode_user) (int cpu,
const void __user *buf, size_t size);

- enum ucode_state (*request_microcode_fw) (int cpu,
+ enum ucode_state (* const request_microcode_fw) (int cpu,
struct device *device);

- void (*microcode_fini_cpu) (int cpu);
+ void (* const microcode_fini_cpu) (int cpu);

/*
* The generic 'microcode_core' part guarantees that
@@ -38,18 +38,18 @@ struct ucode_cpu_info {
extern struct ucode_cpu_info ucode_cpu_info[];

#ifdef CONFIG_MICROCODE_INTEL
-extern struct microcode_ops * __init init_intel_microcode(void);
+extern const struct microcode_ops * __init init_intel_microcode(void);
#else
-static inline struct microcode_ops * __init init_intel_microcode(void)
+static inline const struct microcode_ops * __init init_intel_microcode(void)
{
return NULL;
}
#endif /* CONFIG_MICROCODE_INTEL */

#ifdef CONFIG_MICROCODE_AMD
-extern struct microcode_ops * __init init_amd_microcode(void);
+extern const struct microcode_ops * __init init_amd_microcode(void);
#else
-static inline struct microcode_ops * __init init_amd_microcode(void)
+static inline const struct microcode_ops * __init init_amd_microcode(void)
{
return NULL;
}
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index f4c538b..9a7238c 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -346,7 +346,7 @@ static void microcode_fini_cpu_amd(int cpu)
uci->mc = NULL;
}

-static struct microcode_ops microcode_amd_ops = {
+static const struct microcode_ops microcode_amd_ops = {
.request_microcode_user = request_microcode_user,
.request_microcode_fw = request_microcode_fw,
.collect_cpu_info = collect_cpu_info_amd,
@@ -354,7 +354,7 @@ static struct microcode_ops microcode_amd_ops = {
.microcode_fini_cpu = microcode_fini_cpu_amd,
};

-struct microcode_ops * __init init_amd_microcode(void)
+const struct microcode_ops * __init init_amd_microcode(void)
{
return &microcode_amd_ops;
}
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index 378e9a8..b5a6ea9 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -90,7 +90,7 @@ MODULE_LICENSE("GPL");

#define MICROCODE_VERSION "2.00"

-static struct microcode_ops *microcode_ops;
+static const struct microcode_ops *microcode_ops;

/*
* Synchronization.
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
index 0d334dd..0f9b41d 100644
--- a/arch/x86/kernel/microcode_intel.c
+++ b/arch/x86/kernel/microcode_intel.c
@@ -460,7 +460,7 @@ static void microcode_fini_cpu(int cpu)
uci->mc = NULL;
}

-static struct microcode_ops microcode_intel_ops = {
+static const struct microcode_ops microcode_intel_ops = {
.request_microcode_user = request_microcode_user,
.request_microcode_fw = request_microcode_fw,
.collect_cpu_info = collect_cpu_info,
@@ -468,7 +468,7 @@ static struct microcode_ops microcode_intel_ops = {
.microcode_fini_cpu = microcode_fini_cpu,
};

-struct microcode_ops * __init init_intel_microcode(void)
+const struct microcode_ops * __init init_intel_microcode(void)
{
return &microcode_intel_ops;
}

2009-12-04 22:37:30

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 21/31] Constify struct mtrr_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct mtrr_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/x86/kernel/cpu/mtrr/amd.c | 2 +-
arch/x86/kernel/cpu/mtrr/centaur.c | 2 +-
arch/x86/kernel/cpu/mtrr/cyrix.c | 2 +-
arch/x86/kernel/cpu/mtrr/generic.c | 2 +-
arch/x86/kernel/cpu/mtrr/main.c | 6 +++---
arch/x86/kernel/cpu/mtrr/mtrr.h | 22 +++++++++++-----------
6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/amd.c b/arch/x86/kernel/cpu/mtrr/amd.c
index 33af141..92ba9cd 100644
--- a/arch/x86/kernel/cpu/mtrr/amd.c
+++ b/arch/x86/kernel/cpu/mtrr/amd.c
@@ -108,7 +108,7 @@ amd_validate_add_page(unsigned long base, unsigned long size, unsigned int type)
return 0;
}

-static struct mtrr_ops amd_mtrr_ops = {
+static const struct mtrr_ops amd_mtrr_ops = {
.vendor = X86_VENDOR_AMD,
.set = amd_set_mtrr,
.get = amd_get_mtrr,
diff --git a/arch/x86/kernel/cpu/mtrr/centaur.c b/arch/x86/kernel/cpu/mtrr/centaur.c
index de89f14..316fe3e 100644
--- a/arch/x86/kernel/cpu/mtrr/centaur.c
+++ b/arch/x86/kernel/cpu/mtrr/centaur.c
@@ -110,7 +110,7 @@ centaur_validate_add_page(unsigned long base, unsigned long size, unsigned int t
return 0;
}

-static struct mtrr_ops centaur_mtrr_ops = {
+static const struct mtrr_ops centaur_mtrr_ops = {
.vendor = X86_VENDOR_CENTAUR,
.set = centaur_set_mcr,
.get = centaur_get_mcr,
diff --git a/arch/x86/kernel/cpu/mtrr/cyrix.c b/arch/x86/kernel/cpu/mtrr/cyrix.c
index 228d982..68a3343 100644
--- a/arch/x86/kernel/cpu/mtrr/cyrix.c
+++ b/arch/x86/kernel/cpu/mtrr/cyrix.c
@@ -265,7 +265,7 @@ static void cyrix_set_all(void)
post_set();
}

-static struct mtrr_ops cyrix_mtrr_ops = {
+static const struct mtrr_ops cyrix_mtrr_ops = {
.vendor = X86_VENDOR_CYRIX,
.set_all = cyrix_set_all,
.set = cyrix_set_arr,
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index 55da0c5..4d75584 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -752,7 +752,7 @@ int positive_have_wrcomb(void)
/*
* Generic structure...
*/
-struct mtrr_ops generic_mtrr_ops = {
+const struct mtrr_ops generic_mtrr_ops = {
.use_intel_if = 1,
.set_all = generic_set_all,
.get = generic_get_mtrr,
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 84e83de..fe4622e 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -60,14 +60,14 @@ static DEFINE_MUTEX(mtrr_mutex);
u64 size_or_mask, size_and_mask;
static bool mtrr_aps_delayed_init;

-static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];

-struct mtrr_ops *mtrr_if;
+const struct mtrr_ops *mtrr_if;

static void set_mtrr(unsigned int reg, unsigned long base,
unsigned long size, mtrr_type type);

-void set_mtrr_ops(struct mtrr_ops *ops)
+void set_mtrr_ops(const struct mtrr_ops *ops)
{
if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
mtrr_ops[ops->vendor] = ops;
diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
index a501dee..d94607c 100644
--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
@@ -12,19 +12,19 @@
extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];

struct mtrr_ops {
- u32 vendor;
- u32 use_intel_if;
- void (*set)(unsigned int reg, unsigned long base,
+ const u32 vendor;
+ const u32 use_intel_if;
+ void (* const set)(unsigned int reg, unsigned long base,
unsigned long size, mtrr_type type);
- void (*set_all)(void);
+ void (* const set_all)(void);

- void (*get)(unsigned int reg, unsigned long *base,
+ void (* const get)(unsigned int reg, unsigned long *base,
unsigned long *size, mtrr_type *type);
- int (*get_free_region)(unsigned long base, unsigned long size,
+ int (* const get_free_region)(unsigned long base, unsigned long size,
int replace_reg);
- int (*validate_add_page)(unsigned long base, unsigned long size,
+ int (* const validate_add_page)(unsigned long base, unsigned long size,
unsigned int type);
- int (*have_wrcomb)(void);
+ int (* const have_wrcomb)(void);
};

extern int generic_get_free_region(unsigned long base, unsigned long size,
@@ -32,7 +32,7 @@ extern int generic_get_free_region(unsigned long base, unsigned long size,
extern int generic_validate_add_page(unsigned long base, unsigned long size,
unsigned int type);

-extern struct mtrr_ops generic_mtrr_ops;
+extern const struct mtrr_ops generic_mtrr_ops;

extern int positive_have_wrcomb(void);

@@ -53,10 +53,10 @@ void fill_mtrr_var_range(unsigned int index,
u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);
void get_mtrr_state(void);

-extern void set_mtrr_ops(struct mtrr_ops *ops);
+extern void set_mtrr_ops(const struct mtrr_ops *ops);

extern u64 size_or_mask, size_and_mask;
-extern struct mtrr_ops *mtrr_if;
+extern const struct mtrr_ops *mtrr_if;

#define is_cpu(vnd) (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
#define use_intel() (mtrr_if && mtrr_if->use_intel_if == 1)

2009-12-04 22:37:39

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 22/31] Constify struct neigh_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct neigh_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
include/net/neighbour.h | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 3817fda..2c61d38 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -125,12 +125,12 @@ struct neighbour
struct neigh_ops
{
int family;
- void (*solicit)(struct neighbour *, struct sk_buff*);
- void (*error_report)(struct neighbour *, struct sk_buff*);
- int (*output)(struct sk_buff*);
- int (*connected_output)(struct sk_buff*);
- int (*hh_output)(struct sk_buff*);
- int (*queue_xmit)(struct sk_buff*);
+ void (* const solicit)(struct neighbour *, struct sk_buff*);
+ void (* const error_report)(struct neighbour *, struct sk_buff*);
+ int (* const output)(struct sk_buff*);
+ int (* const connected_output)(struct sk_buff*);
+ int (* const hh_output)(struct sk_buff*);
+ int (* const queue_xmit)(struct sk_buff*);
};

struct pneigh_entry

2009-12-04 22:39:41

by Waskiewicz Jr, Peter P

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

On Fri, 4 Dec 2009, Emese Revfy wrote:

> From: Emese Revfy <[email protected]>
>
> Constify struct e1000_mac_operations with some exceptions.
>
> Signed-off-by: Emese Revfy <[email protected]>

Any networking patches need to be sent to the netdev list and Dave Miller.
I've added those to the CC, and will do the same for the other two e1000
patches in your series.

Cheers,
-PJ

> ---
> drivers/net/e1000e/82571.c | 3 ++-
> drivers/net/e1000e/e1000.h | 2 +-
> drivers/net/e1000e/es2lan.c | 3 ++-
> drivers/net/e1000e/ich8lan.c | 2 +-
> drivers/net/igb/e1000_82575.c | 2 +-
> drivers/net/igb/e1000_hw.h | 2 +-
> 6 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
> index d1e0563..16ffb11 100644
> --- a/drivers/net/e1000e/82571.c
> +++ b/drivers/net/e1000e/82571.c
> @@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
> {
> struct e1000_hw *hw = &adapter->hw;
> struct e1000_mac_info *mac = &hw->mac;
> + /* cannot be const */
> struct e1000_mac_operations *func = &mac->ops;
> u32 swsm = 0;
> u32 swsm2 = 0;
> @@ -1656,7 +1657,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
> temp = er32(ICRXDMTC);
> }
>
> -static struct e1000_mac_operations e82571_mac_ops = {
> +static const struct e1000_mac_operations e82571_mac_ops = {
> /* .check_mng_mode: mac type dependent */
> /* .check_for_link: media type dependent */
> .id_led_init = e1000e_id_led_init,
> diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> index 3e187b0..933f5da 100644
> --- a/drivers/net/e1000e/e1000.h
> +++ b/drivers/net/e1000e/e1000.h
> @@ -375,7 +375,7 @@ struct e1000_info {
> u32 pba;
> u32 max_hw_frame_size;
> s32 (*get_variants)(struct e1000_adapter *);
> - struct e1000_mac_operations *mac_ops;
> + const struct e1000_mac_operations *mac_ops;
> struct e1000_phy_operations *phy_ops;
> struct e1000_nvm_operations *nvm_ops;
> };
> diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
> index ae5d736..06d47e0 100644
> --- a/drivers/net/e1000e/es2lan.c
> +++ b/drivers/net/e1000e/es2lan.c
> @@ -207,6 +207,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
> {
> struct e1000_hw *hw = &adapter->hw;
> struct e1000_mac_info *mac = &hw->mac;
> + /* cannot be const */
> struct e1000_mac_operations *func = &mac->ops;
>
> /* Set media type */
> @@ -1365,7 +1366,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
> temp = er32(ICRXDMTC);
> }
>
> -static struct e1000_mac_operations es2_mac_ops = {
> +static const struct e1000_mac_operations es2_mac_ops = {
> .id_led_init = e1000e_id_led_init,
> .check_mng_mode = e1000e_check_mng_mode_generic,
> /* check_for_link dependent on media type */
> diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
> index eff3f47..3e0065b 100644
> --- a/drivers/net/e1000e/ich8lan.c
> +++ b/drivers/net/e1000e/ich8lan.c
> @@ -3451,7 +3451,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
> }
> }
>
> -static struct e1000_mac_operations ich8_mac_ops = {
> +static const struct e1000_mac_operations ich8_mac_ops = {
> .id_led_init = e1000e_id_led_init,
> .check_mng_mode = e1000_check_mng_mode_ich8lan,
> .check_for_link = e1000_check_for_copper_link_ich8lan,
> diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
> index f8f5772..3d5794f 100644
> --- a/drivers/net/igb/e1000_82575.c
> +++ b/drivers/net/igb/e1000_82575.c
> @@ -1400,7 +1400,7 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
> wr32(E1000_VT_CTL, vt_ctl);
> }
>
> -static struct e1000_mac_operations e1000_mac_ops_82575 = {
> +static const struct e1000_mac_operations e1000_mac_ops_82575 = {
> .reset_hw = igb_reset_hw_82575,
> .init_hw = igb_init_hw_82575,
> .check_for_link = igb_check_for_link_82575,
> diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
> index 119869b..d58b7e5 100644
> --- a/drivers/net/igb/e1000_hw.h
> +++ b/drivers/net/igb/e1000_hw.h
> @@ -310,7 +310,7 @@ struct e1000_nvm_operations {
>
> struct e1000_info {
> s32 (*get_invariants)(struct e1000_hw *);
> - struct e1000_mac_operations *mac_ops;
> + const struct e1000_mac_operations *mac_ops;
> struct e1000_phy_operations *phy_ops;
> struct e1000_nvm_operations *nvm_ops;
> };
>
>

2009-12-04 22:40:37

by Waskiewicz Jr, Peter P

[permalink] [raw]
Subject: Re: [PATCH 07/31] Constify struct e1000_nvm_operations for 2.6.32 v1

On Fri, 4 Dec 2009, Emese Revfy wrote:

> From: Emese Revfy <[email protected]>
>
> Constify struct e1000_nvm_operations.
>
> Signed-off-by: Emese Revfy <[email protected]>

Added Dave Miller and netdev.

> ---
> drivers/net/e1000e/82571.c | 2 +-
> drivers/net/e1000e/e1000.h | 2 +-
> drivers/net/e1000e/es2lan.c | 2 +-
> drivers/net/e1000e/hw.h | 16 ++++++++--------
> drivers/net/e1000e/ich8lan.c | 2 +-
> drivers/net/igb/e1000_82575.c | 2 +-
> drivers/net/igb/e1000_hw.h | 12 ++++++------
> 7 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
> index d1e0563..2a2355f 100644
> --- a/drivers/net/e1000e/82571.c
> +++ b/drivers/net/e1000e/82571.c
> @@ -1725,7 +1725,7 @@ static struct e1000_phy_operations e82_phy_ops_bm = {
> .cfg_on_link_up = NULL,
> };
>
> -static struct e1000_nvm_operations e82571_nvm_ops = {
> +static const struct e1000_nvm_operations e82571_nvm_ops = {
> .acquire_nvm = e1000_acquire_nvm_82571,
> .read_nvm = e1000e_read_nvm_eerd,
> .release_nvm = e1000_release_nvm_82571,
> diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> index 3e187b0..bcdcfb1 100644
> --- a/drivers/net/e1000e/e1000.h
> +++ b/drivers/net/e1000e/e1000.h
> @@ -377,7 +377,7 @@ struct e1000_info {
> s32 (*get_variants)(struct e1000_adapter *);
> struct e1000_mac_operations *mac_ops;
> struct e1000_phy_operations *phy_ops;
> - struct e1000_nvm_operations *nvm_ops;
> + const struct e1000_nvm_operations *nvm_ops;
> };
>
> /* hardware capability, feature, and workaround flags */
> diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
> index ae5d736..a980900 100644
> --- a/drivers/net/e1000e/es2lan.c
> +++ b/drivers/net/e1000e/es2lan.c
> @@ -1400,7 +1400,7 @@ static struct e1000_phy_operations es2_phy_ops = {
> .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
> };
>
> -static struct e1000_nvm_operations es2_nvm_ops = {
> +static const struct e1000_nvm_operations es2_nvm_ops = {
> .acquire_nvm = e1000_acquire_nvm_80003es2lan,
> .read_nvm = e1000e_read_nvm_eerd,
> .release_nvm = e1000_release_nvm_80003es2lan,
> diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
> index aaea41e..f7f181f 100644
> --- a/drivers/net/e1000e/hw.h
> +++ b/drivers/net/e1000e/hw.h
> @@ -776,13 +776,13 @@ struct e1000_phy_operations {
>
> /* Function pointers for the NVM. */
> struct e1000_nvm_operations {
> - s32 (*acquire_nvm)(struct e1000_hw *);
> - s32 (*read_nvm)(struct e1000_hw *, u16, u16, u16 *);
> - void (*release_nvm)(struct e1000_hw *);
> - s32 (*update_nvm)(struct e1000_hw *);
> - s32 (*valid_led_default)(struct e1000_hw *, u16 *);
> - s32 (*validate_nvm)(struct e1000_hw *);
> - s32 (*write_nvm)(struct e1000_hw *, u16, u16, u16 *);
> + s32 (* const acquire_nvm)(struct e1000_hw *);
> + s32 (* const read_nvm)(struct e1000_hw *, u16, u16, u16 *);
> + void (* const release_nvm)(struct e1000_hw *);
> + s32 (* const update_nvm)(struct e1000_hw *);
> + s32 (* const valid_led_default)(struct e1000_hw *, u16 *);
> + s32 (* const validate_nvm)(struct e1000_hw *);
> + s32 (* const write_nvm)(struct e1000_hw *, u16, u16, u16 *);
> };
>
> struct e1000_mac_info {
> @@ -856,7 +856,7 @@ struct e1000_phy_info {
> };
>
> struct e1000_nvm_info {
> - struct e1000_nvm_operations ops;
> + const struct e1000_nvm_operations ops;
>
> enum e1000_nvm_type type;
> enum e1000_nvm_override override;
> diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
> index eff3f47..8835afa 100644
> --- a/drivers/net/e1000e/ich8lan.c
> +++ b/drivers/net/e1000e/ich8lan.c
> @@ -3485,7 +3485,7 @@ static struct e1000_phy_operations ich8_phy_ops = {
> .write_phy_reg = e1000e_write_phy_reg_igp,
> };
>
> -static struct e1000_nvm_operations ich8_nvm_ops = {
> +static const struct e1000_nvm_operations ich8_nvm_ops = {
> .acquire_nvm = e1000_acquire_nvm_ich8lan,
> .read_nvm = e1000_read_nvm_ich8lan,
> .release_nvm = e1000_release_nvm_ich8lan,
> diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
> index f8f5772..f62d4e1 100644
> --- a/drivers/net/igb/e1000_82575.c
> +++ b/drivers/net/igb/e1000_82575.c
> @@ -1415,7 +1415,7 @@ static struct e1000_phy_operations e1000_phy_ops_82575 = {
> .release = igb_release_phy_82575,
> };
>
> -static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
> +static const struct e1000_nvm_operations e1000_nvm_ops_82575 = {
> .acquire = igb_acquire_nvm_82575,
> .read = igb_read_nvm_eerd,
> .release = igb_release_nvm_82575,
> diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
> index 119869b..c31e6b2 100644
> --- a/drivers/net/igb/e1000_hw.h
> +++ b/drivers/net/igb/e1000_hw.h
> @@ -302,17 +302,17 @@ struct e1000_phy_operations {
> };
>
> struct e1000_nvm_operations {
> - s32 (*acquire)(struct e1000_hw *);
> - s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
> - void (*release)(struct e1000_hw *);
> - s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
> + s32 (* const acquire)(struct e1000_hw *);
> + s32 (* const read)(struct e1000_hw *, u16, u16, u16 *);
> + void (* const release)(struct e1000_hw *);
> + s32 (* const write)(struct e1000_hw *, u16, u16, u16 *);
> };
>
> struct e1000_info {
> s32 (*get_invariants)(struct e1000_hw *);
> struct e1000_mac_operations *mac_ops;
> struct e1000_phy_operations *phy_ops;
> - struct e1000_nvm_operations *nvm_ops;
> + const struct e1000_nvm_operations *nvm_ops;
> };
>
> extern const struct e1000_info e1000_82575_info;
> @@ -397,7 +397,7 @@ struct e1000_phy_info {
> };
>
> struct e1000_nvm_info {
> - struct e1000_nvm_operations ops;
> + const struct e1000_nvm_operations ops;
>
> enum e1000_nvm_type type;
> enum e1000_nvm_override override;
>
>

2009-12-04 22:38:43

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 23/31] Constify struct nlmsvc_binding for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct nlmsvc_binding.

Signed-off-by: Emese Revfy <[email protected]>
---
fs/lockd/svc.c | 2 +-
fs/nfsd/lockd.c | 2 +-
include/linux/lockd/bind.h | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 1a54ae1..6a16c27 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -43,7 +43,7 @@

static struct svc_program nlmsvc_program;

-struct nlmsvc_binding * nlmsvc_ops;
+const struct nlmsvc_binding * nlmsvc_ops;
EXPORT_SYMBOL_GPL(nlmsvc_ops);

static DEFINE_MUTEX(nlmsvc_mutex);
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index b2786a5..f717a27 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -67,7 +67,7 @@ nlm_fclose(struct file *filp)
fput(filp);
}

-static struct nlmsvc_binding nfsd_nlm_ops = {
+static const struct nlmsvc_binding nfsd_nlm_ops = {
.fopen = nlm_fopen, /* open file for locking */
.fclose = nlm_fclose, /* close file */
};
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index fbc48f8..0886e57 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -23,13 +23,13 @@ struct svc_rqst;
* This is the set of functions for lockd->nfsd communication
*/
struct nlmsvc_binding {
- __be32 (*fopen)(struct svc_rqst *,
+ __be32 (* const fopen)(struct svc_rqst *,
struct nfs_fh *,
struct file **);
- void (*fclose)(struct file *);
+ void (* const fclose)(struct file *);
};

-extern struct nlmsvc_binding * nlmsvc_ops;
+extern const struct nlmsvc_binding * nlmsvc_ops;

/*
* Similar to nfs_client_initdata, but without the NFS-specific

2009-12-04 22:40:53

by Waskiewicz Jr, Peter P

[permalink] [raw]
Subject: Re: [PATCH 08/31] Constify struct e1000_phy_operations for 2.6.32 v1

On Fri, 4 Dec 2009, Emese Revfy wrote:

> From: Emese Revfy <[email protected]>
>
> Constify struct e1000_phy_operations.
>
> Signed-off-by: Emese Revfy <[email protected]>

Added Dave Miller and netdev.

> ---
> drivers/net/e1000e/82571.c | 6 +++---
> drivers/net/e1000e/e1000.h | 2 +-
> drivers/net/e1000e/es2lan.c | 2 +-
> drivers/net/e1000e/ich8lan.c | 2 +-
> drivers/net/igb/e1000_82575.c | 2 +-
> drivers/net/igb/e1000_hw.h | 2 +-
> 6 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
> index d1e0563..9457254 100644
> --- a/drivers/net/e1000e/82571.c
> +++ b/drivers/net/e1000e/82571.c
> @@ -1674,7 +1674,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
> .setup_led = e1000e_setup_led_generic,
> };
>
> -static struct e1000_phy_operations e82_phy_ops_igp = {
> +static const struct e1000_phy_operations e82_phy_ops_igp = {
> .acquire_phy = e1000_get_hw_semaphore_82571,
> .check_reset_block = e1000e_check_reset_block_generic,
> .commit_phy = NULL,
> @@ -1691,7 +1691,7 @@ static struct e1000_phy_operations e82_phy_ops_igp = {
> .cfg_on_link_up = NULL,
> };
>
> -static struct e1000_phy_operations e82_phy_ops_m88 = {
> +static const struct e1000_phy_operations e82_phy_ops_m88 = {
> .acquire_phy = e1000_get_hw_semaphore_82571,
> .check_reset_block = e1000e_check_reset_block_generic,
> .commit_phy = e1000e_phy_sw_reset,
> @@ -1708,7 +1708,7 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
> .cfg_on_link_up = NULL,
> };
>
> -static struct e1000_phy_operations e82_phy_ops_bm = {
> +static const struct e1000_phy_operations e82_phy_ops_bm = {
> .acquire_phy = e1000_get_hw_semaphore_82571,
> .check_reset_block = e1000e_check_reset_block_generic,
> .commit_phy = e1000e_phy_sw_reset,
> diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> index 3e187b0..7744c27 100644
> --- a/drivers/net/e1000e/e1000.h
> +++ b/drivers/net/e1000e/e1000.h
> @@ -376,7 +376,7 @@ struct e1000_info {
> u32 max_hw_frame_size;
> s32 (*get_variants)(struct e1000_adapter *);
> struct e1000_mac_operations *mac_ops;
> - struct e1000_phy_operations *phy_ops;
> + const struct e1000_phy_operations *phy_ops;
> struct e1000_nvm_operations *nvm_ops;
> };
>
> diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
> index ae5d736..631c037 100644
> --- a/drivers/net/e1000e/es2lan.c
> +++ b/drivers/net/e1000e/es2lan.c
> @@ -1383,7 +1383,7 @@ static struct e1000_mac_operations es2_mac_ops = {
> .setup_led = e1000e_setup_led_generic,
> };
>
> -static struct e1000_phy_operations es2_phy_ops = {
> +static const struct e1000_phy_operations es2_phy_ops = {
> .acquire_phy = e1000_acquire_phy_80003es2lan,
> .check_reset_block = e1000e_check_reset_block_generic,
> .commit_phy = e1000e_phy_sw_reset,
> diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
> index eff3f47..ca9d830 100644
> --- a/drivers/net/e1000e/ich8lan.c
> +++ b/drivers/net/e1000e/ich8lan.c
> @@ -3469,7 +3469,7 @@ static struct e1000_mac_operations ich8_mac_ops = {
> /* id_led_init dependent on mac type */
> };
>
> -static struct e1000_phy_operations ich8_phy_ops = {
> +static const struct e1000_phy_operations ich8_phy_ops = {
> .acquire_phy = e1000_acquire_swflag_ich8lan,
> .check_reset_block = e1000_check_reset_block_ich8lan,
> .commit_phy = NULL,
> diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
> index f8f5772..a3e64ae 100644
> --- a/drivers/net/igb/e1000_82575.c
> +++ b/drivers/net/igb/e1000_82575.c
> @@ -1409,7 +1409,7 @@ static struct e1000_mac_operations e1000_mac_ops_82575 = {
> .get_speed_and_duplex = igb_get_speed_and_duplex_copper,
> };
>
> -static struct e1000_phy_operations e1000_phy_ops_82575 = {
> +static const struct e1000_phy_operations e1000_phy_ops_82575 = {
> .acquire = igb_acquire_phy_82575,
> .get_cfg_done = igb_get_cfg_done_82575,
> .release = igb_release_phy_82575,
> diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
> index 119869b..326e0e7 100644
> --- a/drivers/net/igb/e1000_hw.h
> +++ b/drivers/net/igb/e1000_hw.h
> @@ -311,7 +311,7 @@ struct e1000_nvm_operations {
> struct e1000_info {
> s32 (*get_invariants)(struct e1000_hw *);
> struct e1000_mac_operations *mac_ops;
> - struct e1000_phy_operations *phy_ops;
> + const struct e1000_phy_operations *phy_ops;
> struct e1000_nvm_operations *nvm_ops;
> };
>
>

2009-12-04 22:40:08

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 24/31] Constify struct pci_raw_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct pci_raw_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/x86/include/asm/pci_x86.h | 10 +++++-----
arch/x86/pci/common.c | 4 ++--
arch/x86/pci/direct.c | 6 +++---
arch/x86/pci/mmconfig_32.c | 2 +-
arch/x86/pci/mmconfig_64.c | 2 +-
arch/x86/pci/numaq_32.c | 2 +-
arch/x86/pci/olpc.c | 2 +-
arch/x86/pci/pcbios.c | 4 ++--
8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index b399988..3f47c38 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -89,16 +89,16 @@ extern int (*pcibios_enable_irq)(struct pci_dev *dev);
extern void (*pcibios_disable_irq)(struct pci_dev *dev);

struct pci_raw_ops {
- int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
+ int (* const read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val);
- int (*write)(unsigned int domain, unsigned int bus, unsigned int devfn,
+ int (* const write)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 val);
};

-extern struct pci_raw_ops *raw_pci_ops;
-extern struct pci_raw_ops *raw_pci_ext_ops;
+extern const struct pci_raw_ops *raw_pci_ops;
+extern const struct pci_raw_ops *raw_pci_ext_ops;

-extern struct pci_raw_ops pci_direct_conf1;
+extern const struct pci_raw_ops pci_direct_conf1;
extern bool port_cf9_safe;

/* arch_initcall level */
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 1331fcf..03901b2 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -31,8 +31,8 @@ int noioapicreroute = 1;
int pcibios_last_bus = -1;
unsigned long pirq_table_addr;
struct pci_bus *pci_root_bus;
-struct pci_raw_ops *raw_pci_ops;
-struct pci_raw_ops *raw_pci_ext_ops;
+const struct pci_raw_ops *raw_pci_ops;
+const struct pci_raw_ops *raw_pci_ext_ops;

int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val)
diff --git a/arch/x86/pci/direct.c b/arch/x86/pci/direct.c
index 347d882..4baf6b6 100644
--- a/arch/x86/pci/direct.c
+++ b/arch/x86/pci/direct.c
@@ -79,7 +79,7 @@ static int pci_conf1_write(unsigned int seg, unsigned int bus,

#undef PCI_CONF1_ADDRESS

-struct pci_raw_ops pci_direct_conf1 = {
+const struct pci_raw_ops pci_direct_conf1 = {
.read = pci_conf1_read,
.write = pci_conf1_write,
};
@@ -173,7 +173,7 @@ static int pci_conf2_write(unsigned int seg, unsigned int bus,

#undef PCI_CONF2_ADDRESS

-struct pci_raw_ops pci_direct_conf2 = {
+const struct pci_raw_ops pci_direct_conf2 = {
.read = pci_conf2_read,
.write = pci_conf2_write,
};
@@ -189,7 +189,7 @@ struct pci_raw_ops pci_direct_conf2 = {
* This should be close to trivial, but it isn't, because there are buggy
* chipsets (yes, you guessed it, by Intel and Compaq) that have no class ID.
*/
-static int __init pci_sanity_check(struct pci_raw_ops *o)
+static int __init pci_sanity_check(const struct pci_raw_ops *o)
{
u32 x = 0;
int year, devfn;
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c
index f10a7e9..0425342 100644
--- a/arch/x86/pci/mmconfig_32.c
+++ b/arch/x86/pci/mmconfig_32.c
@@ -125,7 +125,7 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
return 0;
}

-static struct pci_raw_ops pci_mmcfg = {
+static const struct pci_raw_ops pci_mmcfg = {
.read = pci_mmcfg_read,
.write = pci_mmcfg_write,
};
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index 94349f8..41600a7 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -104,7 +104,7 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
return 0;
}

-static struct pci_raw_ops pci_mmcfg = {
+static const struct pci_raw_ops pci_mmcfg = {
.read = pci_mmcfg_read,
.write = pci_mmcfg_write,
};
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index 8eb295e..86bd657 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -112,7 +112,7 @@ static int pci_conf1_mq_write(unsigned int seg, unsigned int bus,

#undef PCI_CONF1_MQ_ADDRESS

-static struct pci_raw_ops pci_direct_conf1_mq = {
+static const struct pci_raw_ops pci_direct_conf1_mq = {
.read = pci_conf1_mq_read,
.write = pci_conf1_mq_write
};
diff --git a/arch/x86/pci/olpc.c b/arch/x86/pci/olpc.c
index b889d82..5a58a0a 100644
--- a/arch/x86/pci/olpc.c
+++ b/arch/x86/pci/olpc.c
@@ -297,7 +297,7 @@ static int pci_olpc_write(unsigned int seg, unsigned int bus,
return 0;
}

-static struct pci_raw_ops pci_olpc_conf = {
+static const struct pci_raw_ops pci_olpc_conf = {
.read = pci_olpc_read,
.write = pci_olpc_write,
};
diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
index 1c975cc..5fa1cff 100644
--- a/arch/x86/pci/pcbios.c
+++ b/arch/x86/pci/pcbios.c
@@ -278,7 +278,7 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
* Function table for BIOS32 access
*/

-static struct pci_raw_ops pci_bios_access = {
+static const struct pci_raw_ops pci_bios_access = {
.read = pci_bios_read,
.write = pci_bios_write
};
@@ -287,7 +287,7 @@ static struct pci_raw_ops pci_bios_access = {
* Try to find PCI BIOS.
*/

-static struct pci_raw_ops * __devinit pci_find_bios(void)
+static const struct pci_raw_ops * __devinit pci_find_bios(void)
{
union bios32 *check;
unsigned char sum;

2009-12-04 22:41:27

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 25/31] Constify struct platform_hibernation_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct platform_hibernation_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/sleep.c | 4 ++--
include/linux/suspend.h | 24 ++++++++++++------------
kernel/power/hibernate.c | 4 ++--
3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 5f2c379..3f5957a 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -552,7 +552,7 @@ static void acpi_pm_enable_gpes(void)
acpi_enable_all_runtime_gpes();
}

-static struct platform_hibernation_ops acpi_hibernation_ops = {
+static const struct platform_hibernation_ops acpi_hibernation_ops = {
.begin = acpi_hibernation_begin,
.end = acpi_pm_end,
.pre_snapshot = acpi_hibernation_pre_snapshot,
@@ -605,7 +605,7 @@ static int acpi_hibernation_pre_snapshot_old(void)
* The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
* been requested.
*/
-static struct platform_hibernation_ops acpi_hibernation_ops_old = {
+static const struct platform_hibernation_ops acpi_hibernation_ops_old = {
.begin = acpi_hibernation_begin_old,
.end = acpi_pm_end,
.pre_snapshot = acpi_hibernation_pre_snapshot_old,
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5e781d8..cb4cc7d 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -215,16 +215,16 @@ extern void mark_free_pages(struct zone *zone);
* platforms which require special recovery actions in that situation.
*/
struct platform_hibernation_ops {
- int (*begin)(void);
- void (*end)(void);
- int (*pre_snapshot)(void);
- void (*finish)(void);
- int (*prepare)(void);
- int (*enter)(void);
- void (*leave)(void);
- int (*pre_restore)(void);
- void (*restore_cleanup)(void);
- void (*recover)(void);
+ int (* const begin)(void);
+ void (* const end)(void);
+ int (* const pre_snapshot)(void);
+ void (* const finish)(void);
+ int (* const prepare)(void);
+ int (* const enter)(void);
+ void (* const leave)(void);
+ int (* const pre_restore)(void);
+ void (* const restore_cleanup)(void);
+ void (* const recover)(void);
};

#ifdef CONFIG_HIBERNATION
@@ -243,7 +243,7 @@ extern void swsusp_set_page_free(struct page *);
extern void swsusp_unset_page_free(struct page *);
extern unsigned long get_safe_page(gfp_t gfp_mask);

-extern void hibernation_set_ops(struct platform_hibernation_ops *ops);
+extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
extern int hibernate(void);
extern bool system_entering_hibernation(void);
#else /* CONFIG_HIBERNATION */
@@ -251,7 +251,7 @@ static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
static inline void swsusp_set_page_free(struct page *p) {}
static inline void swsusp_unset_page_free(struct page *p) {}

-static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
+static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
static inline int hibernate(void) { return -ENOSYS; }
static inline bool system_entering_hibernation(void) { return false; }
#endif /* CONFIG_HIBERNATION */
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 04a9e90..bc355aa 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -48,14 +48,14 @@ enum {

static int hibernation_mode = HIBERNATION_SHUTDOWN;

-static struct platform_hibernation_ops *hibernation_ops;
+static const struct platform_hibernation_ops *hibernation_ops;

/**
* hibernation_set_ops - set the global hibernate operations
* @ops: the hibernation operations to use in subsequent hibernation transitions
*/

-void hibernation_set_ops(struct platform_hibernation_ops *ops)
+void hibernation_set_ops(const struct platform_hibernation_ops *ops)
{
if (ops && !(ops->begin && ops->end && ops->pre_snapshot
&& ops->prepare && ops->finish && ops->enter && ops->pre_restore

2009-12-04 22:42:58

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 26/31] Constify struct platform_suspend_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct platform_suspend_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/arm/mach-at91/pm.c | 2 +-
arch/arm/mach-omap1/pm.c | 2 +-
arch/arm/mach-omap2/pm24xx.c | 2 +-
arch/arm/mach-omap2/pm34xx.c | 2 +-
arch/arm/mach-pnx4008/pm.c | 2 +-
arch/arm/mach-pxa/pm.c | 2 +-
arch/arm/mach-pxa/sharpsl_pm.c | 2 +-
arch/arm/mach-sa1100/pm.c | 2 +-
arch/arm/plat-s3c/pm.c | 2 +-
arch/avr32/mach-at32ap/pm.c | 2 +-
arch/blackfin/mach-common/pm.c | 2 +-
arch/mips/alchemy/devboards/pm.c | 2 +-
arch/powerpc/platforms/52xx/lite5200_pm.c | 2 +-
arch/powerpc/platforms/52xx/mpc52xx_pm.c | 2 +-
arch/powerpc/platforms/83xx/suspend.c | 2 +-
arch/sh/boards/mach-hp6xx/pm.c | 2 +-
arch/sh/kernel/cpu/shmobile/pm.c | 2 +-
drivers/acpi/sleep.c | 4 ++--
drivers/macintosh/via-pmu.c | 2 +-
include/linux/suspend.h | 22 +++++++++++-----------
kernel/power/suspend.c | 4 ++--
21 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 4028724..beec230 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -348,7 +348,7 @@ static void at91_pm_end(void)
}


-static struct platform_suspend_ops at91_pm_ops ={
+static const struct platform_suspend_ops at91_pm_ops ={
.valid = at91_pm_valid_state,
.begin = at91_pm_begin,
.enter = at91_pm_enter,
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 5218943..0a34552 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -647,7 +647,7 @@ static struct irqaction omap_wakeup_irq = {



-static struct platform_suspend_ops omap_pm_ops ={
+static const struct platform_suspend_ops omap_pm_ops ={
.prepare = omap_pm_prepare,
.enter = omap_pm_enter,
.finish = omap_pm_finish,
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index bff5c4e..d4c649b 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -326,7 +326,7 @@ static void omap2_pm_finish(void)
enable_hlt();
}

-static struct platform_suspend_ops omap_pm_ops = {
+static const struct platform_suspend_ops omap_pm_ops = {
.prepare = omap2_pm_prepare,
.enter = omap2_pm_enter,
.finish = omap2_pm_finish,
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 8946319..7d3e661 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -401,7 +401,7 @@ static void omap3_pm_end(void)
return;
}

-static struct platform_suspend_ops omap_pm_ops = {
+static const struct platform_suspend_ops omap_pm_ops = {
.begin = omap3_pm_begin,
.end = omap3_pm_end,
.prepare = omap3_pm_prepare,
diff --git a/arch/arm/mach-pnx4008/pm.c b/arch/arm/mach-pnx4008/pm.c
index b3d8d53..6e68ebc 100644
--- a/arch/arm/mach-pnx4008/pm.c
+++ b/arch/arm/mach-pnx4008/pm.c
@@ -116,7 +116,7 @@ static int pnx4008_pm_valid(suspend_state_t state)
(state == PM_SUSPEND_MEM);
}

-static struct platform_suspend_ops pnx4008_pm_ops = {
+static const struct platform_suspend_ops pnx4008_pm_ops = {
.enter = pnx4008_pm_enter,
.valid = pnx4008_pm_valid,
};
diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
index 7693355..9beb00a 100644
--- a/arch/arm/mach-pxa/pm.c
+++ b/arch/arm/mach-pxa/pm.c
@@ -95,7 +95,7 @@ void pxa_pm_finish(void)
pxa_cpu_pm_fns->finish();
}

-static struct platform_suspend_ops pxa_pm_ops = {
+static const struct platform_suspend_ops pxa_pm_ops = {
.valid = pxa_pm_valid,
.enter = pxa_pm_enter,
.prepare = pxa_pm_prepare,
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 629e05d..06be589 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -891,7 +891,7 @@ static void sharpsl_apm_get_power_status(struct apm_power_info *info)
}

#ifdef CONFIG_PM
-static struct platform_suspend_ops sharpsl_pm_ops = {
+static const struct platform_suspend_ops sharpsl_pm_ops = {
.prepare = pxa_pm_prepare,
.finish = pxa_pm_finish,
.enter = corgi_pxa_pm_enter,
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index c83fdc8..ab9fc44 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -120,7 +120,7 @@ unsigned long sleep_phys_sp(void *sp)
return virt_to_phys(sp);
}

-static struct platform_suspend_ops sa11x0_pm_ops = {
+static const struct platform_suspend_ops sa11x0_pm_ops = {
.enter = sa11x0_pm_enter,
.valid = suspend_valid_only_mem,
};
diff --git a/arch/arm/plat-s3c/pm.c b/arch/arm/plat-s3c/pm.c
index 8d97db2..b66cfa5 100644
--- a/arch/arm/plat-s3c/pm.c
+++ b/arch/arm/plat-s3c/pm.c
@@ -355,7 +355,7 @@ static void s3c_pm_finish(void)
s3c_pm_check_cleanup();
}

-static struct platform_suspend_ops s3c_pm_ops = {
+static const struct platform_suspend_ops s3c_pm_ops = {
.enter = s3c_pm_enter,
.prepare = s3c_pm_prepare,
.finish = s3c_pm_finish,
diff --git a/arch/avr32/mach-at32ap/pm.c b/arch/avr32/mach-at32ap/pm.c
index f021edf..32d680e 100644
--- a/arch/avr32/mach-at32ap/pm.c
+++ b/arch/avr32/mach-at32ap/pm.c
@@ -176,7 +176,7 @@ out:
return 0;
}

-static struct platform_suspend_ops avr32_pm_ops = {
+static const struct platform_suspend_ops avr32_pm_ops = {
.valid = avr32_pm_valid_state,
.enter = avr32_pm_enter,
};
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index 8837be4..b2fb413 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -255,7 +255,7 @@ static int bfin_pm_enter(suspend_state_t state)
return 0;
}

-struct platform_suspend_ops bfin_pm_ops = {
+const struct platform_suspend_ops bfin_pm_ops = {
.enter = bfin_pm_enter,
.valid = bfin_pm_valid,
};
diff --git a/arch/mips/alchemy/devboards/pm.c b/arch/mips/alchemy/devboards/pm.c
index 632f986..fd0378d 100644
--- a/arch/mips/alchemy/devboards/pm.c
+++ b/arch/mips/alchemy/devboards/pm.c
@@ -78,7 +78,7 @@ static void db1x_pm_end(void)

}

-static struct platform_suspend_ops db1x_pm_ops = {
+static const struct platform_suspend_ops db1x_pm_ops = {
.valid = suspend_valid_only_mem,
.begin = db1x_pm_begin,
.enter = db1x_pm_enter,
diff --git a/arch/powerpc/platforms/52xx/lite5200_pm.c b/arch/powerpc/platforms/52xx/lite5200_pm.c
index b5c753d..8f01abe 100644
--- a/arch/powerpc/platforms/52xx/lite5200_pm.c
+++ b/arch/powerpc/platforms/52xx/lite5200_pm.c
@@ -235,7 +235,7 @@ static void lite5200_pm_end(void)
lite5200_pm_target_state = PM_SUSPEND_ON;
}

-static struct platform_suspend_ops lite5200_pm_ops = {
+static const struct platform_suspend_ops lite5200_pm_ops = {
.valid = lite5200_pm_valid,
.begin = lite5200_pm_begin,
.prepare = lite5200_pm_prepare,
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pm.c b/arch/powerpc/platforms/52xx/mpc52xx_pm.c
index a55b0b6..478c18e 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pm.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pm.c
@@ -180,7 +180,7 @@ void mpc52xx_pm_finish(void)
iounmap(mbar);
}

-static struct platform_suspend_ops mpc52xx_pm_ops = {
+static const struct platform_suspend_ops mpc52xx_pm_ops = {
.valid = mpc52xx_pm_valid,
.prepare = mpc52xx_pm_prepare,
.enter = mpc52xx_pm_enter,
diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c
index 08e65fc..643d3ac 100644
--- a/arch/powerpc/platforms/83xx/suspend.c
+++ b/arch/powerpc/platforms/83xx/suspend.c
@@ -273,7 +273,7 @@ static int mpc83xx_is_pci_agent(void)
return ret;
}

-static struct platform_suspend_ops mpc83xx_suspend_ops = {
+static const struct platform_suspend_ops mpc83xx_suspend_ops = {
.valid = mpc83xx_suspend_valid,
.begin = mpc83xx_suspend_begin,
.enter = mpc83xx_suspend_enter,
diff --git a/arch/sh/boards/mach-hp6xx/pm.c b/arch/sh/boards/mach-hp6xx/pm.c
index d936c1a..304a252 100644
--- a/arch/sh/boards/mach-hp6xx/pm.c
+++ b/arch/sh/boards/mach-hp6xx/pm.c
@@ -143,7 +143,7 @@ static int hp6x0_pm_enter(suspend_state_t state)
return 0;
}

-static struct platform_suspend_ops hp6x0_pm_ops = {
+static const struct platform_suspend_ops hp6x0_pm_ops = {
.enter = hp6x0_pm_enter,
.valid = suspend_valid_only_mem,
};
diff --git a/arch/sh/kernel/cpu/shmobile/pm.c b/arch/sh/kernel/cpu/shmobile/pm.c
index ee3c2aa..c49cee6 100644
--- a/arch/sh/kernel/cpu/shmobile/pm.c
+++ b/arch/sh/kernel/cpu/shmobile/pm.c
@@ -58,7 +58,7 @@ static int sh_pm_enter(suspend_state_t state)
return 0;
}

-static struct platform_suspend_ops sh_pm_ops = {
+static const struct platform_suspend_ops sh_pm_ops = {
.enter = sh_pm_enter,
.valid = suspend_valid_only_mem,
};
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 5f2c379..1851ae2 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -297,7 +297,7 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
}
}

-static struct platform_suspend_ops acpi_suspend_ops = {
+static const struct platform_suspend_ops acpi_suspend_ops = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin,
.prepare_late = acpi_pm_prepare,
@@ -325,7 +325,7 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
* The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
* been requested.
*/
-static struct platform_suspend_ops acpi_suspend_ops_old = {
+static const struct platform_suspend_ops acpi_suspend_ops_old = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin_old,
.prepare_late = acpi_pm_disable_gpes,
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 6f308a4..b5f7ff7 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2232,7 +2232,7 @@ static int pmu_sleep_valid(suspend_state_t state)
&& (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) >= 0);
}

-static struct platform_suspend_ops pmu_pm_ops = {
+static const struct platform_suspend_ops pmu_pm_ops = {
.enter = powerbook_sleep,
.valid = pmu_sleep_valid,
};
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5e781d8..3a2553d 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -104,15 +104,15 @@ typedef int __bitwise suspend_state_t;
* which require special recovery actions in that situation.
*/
struct platform_suspend_ops {
- int (*valid)(suspend_state_t state);
- int (*begin)(suspend_state_t state);
- int (*prepare)(void);
- int (*prepare_late)(void);
- int (*enter)(suspend_state_t state);
- void (*wake)(void);
- void (*finish)(void);
- void (*end)(void);
- void (*recover)(void);
+ int (* const valid)(suspend_state_t state);
+ int (* const begin)(suspend_state_t state);
+ int (* const prepare)(void);
+ int (* const prepare_late)(void);
+ int (* const enter)(suspend_state_t state);
+ void (* const wake)(void);
+ void (* const finish)(void);
+ void (* const end)(void);
+ void (* const recover)(void);
};

#ifdef CONFIG_SUSPEND
@@ -120,7 +120,7 @@ struct platform_suspend_ops {
* suspend_set_ops - set platform dependent suspend operations
* @ops: The new suspend operations to set.
*/
-extern void suspend_set_ops(struct platform_suspend_ops *ops);
+extern void suspend_set_ops(const struct platform_suspend_ops *ops);
extern int suspend_valid_only_mem(suspend_state_t state);

/**
@@ -145,7 +145,7 @@ extern int pm_suspend(suspend_state_t state);
#else /* !CONFIG_SUSPEND */
#define suspend_valid_only_mem NULL

-static inline void suspend_set_ops(struct platform_suspend_ops *ops) {}
+static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
#endif /* !CONFIG_SUSPEND */

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 6f10dfc..08e1e7b 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -23,13 +23,13 @@ const char *const pm_states[PM_SUSPEND_MAX] = {
[PM_SUSPEND_MEM] = "mem",
};

-static struct platform_suspend_ops *suspend_ops;
+static const struct platform_suspend_ops *suspend_ops;

/**
* suspend_set_ops - Set the global suspend method table.
* @ops: Pointer to ops structure.
*/
-void suspend_set_ops(struct platform_suspend_ops *ops)
+void suspend_set_ops(const struct platform_suspend_ops *ops)
{
mutex_lock(&pm_mutex);
suspend_ops = ops;

2009-12-04 22:42:47

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 27/31] Constify struct snd_ac97_build_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct snd_ac97_build_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
include/sound/ac97_codec.h | 16 +++++-----
sound/pci/ac97/ac97_codec.c | 2 +-
sound/pci/ac97/ac97_patch.c | 64 +++++++++++++++++++++---------------------
3 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 3dae3f7..8440d6f 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -419,15 +419,15 @@
struct snd_ac97;

struct snd_ac97_build_ops {
- int (*build_3d) (struct snd_ac97 *ac97);
- int (*build_specific) (struct snd_ac97 *ac97);
- int (*build_spdif) (struct snd_ac97 *ac97);
- int (*build_post_spdif) (struct snd_ac97 *ac97);
+ int (* const build_3d) (struct snd_ac97 *ac97);
+ int (* const build_specific) (struct snd_ac97 *ac97);
+ int (* const build_spdif) (struct snd_ac97 *ac97);
+ int (* const build_post_spdif) (struct snd_ac97 *ac97);
#ifdef CONFIG_PM
- void (*suspend) (struct snd_ac97 *ac97);
- void (*resume) (struct snd_ac97 *ac97);
+ void (* const suspend) (struct snd_ac97 *ac97);
+ void (* const resume) (struct snd_ac97 *ac97);
#endif
- void (*update_jacks) (struct snd_ac97 *ac97); /* for jack-sharing */
+ void (* const update_jacks) (struct snd_ac97 *ac97); /* for jack-sharing */
};

struct snd_ac97_bus_ops {
@@ -477,7 +477,7 @@ struct snd_ac97_template {

struct snd_ac97 {
/* -- lowlevel (hardware) driver specific -- */
- struct snd_ac97_build_ops * build_ops;
+ const struct snd_ac97_build_ops * build_ops;
void *private_data;
void (*private_free) (struct snd_ac97 *ac97);
/* --- */
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 78288db..0406809 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1952,7 +1952,7 @@ static int snd_ac97_dev_disconnect(struct snd_device *device)
}

/* build_ops to do nothing */
-static struct snd_ac97_build_ops null_build_ops;
+static const struct snd_ac97_build_ops null_build_ops;

#ifdef CONFIG_SND_AC97_POWER_SAVE
static void do_update_power(struct work_struct *work)
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 7337abd..bf2d0b9 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -371,7 +371,7 @@ static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_yamaha_ymf743_ops = {
+static const struct snd_ac97_build_ops patch_yamaha_ymf743_ops = {
.build_spdif = patch_yamaha_ymf743_build_spdif,
.build_3d = patch_yamaha_ymf7x3_3d,
};
@@ -455,7 +455,7 @@ static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = {
+static const struct snd_ac97_build_ops patch_yamaha_ymf753_ops = {
.build_3d = patch_yamaha_ymf7x3_3d,
.build_post_spdif = patch_yamaha_ymf753_post_spdif
};
@@ -502,7 +502,7 @@ static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_wolfson_wm9703_ops = {
+static const struct snd_ac97_build_ops patch_wolfson_wm9703_ops = {
.build_specific = patch_wolfson_wm9703_specific,
};

@@ -533,7 +533,7 @@ static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_wolfson_wm9704_ops = {
+static const struct snd_ac97_build_ops patch_wolfson_wm9704_ops = {
.build_specific = patch_wolfson_wm9704_specific,
};

@@ -555,7 +555,7 @@ static int patch_wolfson_wm9705_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = {
+static const struct snd_ac97_build_ops patch_wolfson_wm9705_ops = {
.build_specific = patch_wolfson_wm9705_specific,
};

@@ -692,7 +692,7 @@ static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_wolfson_wm9711_ops = {
+static const struct snd_ac97_build_ops patch_wolfson_wm9711_ops = {
.build_specific = patch_wolfson_wm9711_specific,
};

@@ -886,7 +886,7 @@ static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
}
#endif

-static struct snd_ac97_build_ops patch_wolfson_wm9713_ops = {
+static const struct snd_ac97_build_ops patch_wolfson_wm9713_ops = {
.build_specific = patch_wolfson_wm9713_specific,
.build_3d = patch_wolfson_wm9713_3d,
#ifdef CONFIG_PM
@@ -991,7 +991,7 @@ static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = {
+static const struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = {
.build_3d = patch_sigmatel_stac9700_3d,
.build_specific = patch_sigmatel_stac97xx_specific
};
@@ -1038,7 +1038,7 @@ static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
return patch_sigmatel_stac97xx_specific(ac97);
}

-static struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = {
+static const struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = {
.build_3d = patch_sigmatel_stac9708_3d,
.build_specific = patch_sigmatel_stac9708_specific
};
@@ -1267,7 +1267,7 @@ static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = {
+static const struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = {
.build_3d = patch_sigmatel_stac9700_3d,
.build_specific = patch_sigmatel_stac9758_specific
};
@@ -1342,7 +1342,7 @@ static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_cirrus_ops = {
+static const struct snd_ac97_build_ops patch_cirrus_ops = {
.build_spdif = patch_cirrus_build_spdif
};

@@ -1399,7 +1399,7 @@ static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_conexant_ops = {
+static const struct snd_ac97_build_ops patch_conexant_ops = {
.build_spdif = patch_conexant_build_spdif
};

@@ -1575,7 +1575,7 @@ static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int
}
}

-static struct snd_ac97_build_ops patch_ad1881_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1881_build_ops = {
#ifdef CONFIG_PM
.resume = ad18xx_resume
#endif
@@ -1662,7 +1662,7 @@ static int patch_ad1885_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_ad1885_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1885_build_ops = {
.build_specific = &patch_ad1885_specific,
#ifdef CONFIG_PM
.resume = ad18xx_resume
@@ -1689,7 +1689,7 @@ static int patch_ad1886_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_ad1886_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1886_build_ops = {
.build_specific = &patch_ad1886_specific,
#ifdef CONFIG_PM
.resume = ad18xx_resume
@@ -1893,7 +1893,7 @@ static int patch_ad1981a_specific(struct snd_ac97 * ac97)
ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
}

-static struct snd_ac97_build_ops patch_ad1981a_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1981a_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1981a_specific,
#ifdef CONFIG_PM
@@ -1948,7 +1948,7 @@ static int patch_ad1981b_specific(struct snd_ac97 *ac97)
ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
}

-static struct snd_ac97_build_ops patch_ad1981b_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1981b_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1981b_specific,
#ifdef CONFIG_PM
@@ -2087,7 +2087,7 @@ static int patch_ad1888_specific(struct snd_ac97 *ac97)
return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
}

-static struct snd_ac97_build_ops patch_ad1888_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1888_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1888_specific,
#ifdef CONFIG_PM
@@ -2136,7 +2136,7 @@ static int patch_ad1980_specific(struct snd_ac97 *ac97)
return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
}

-static struct snd_ac97_build_ops patch_ad1980_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1980_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1980_specific,
#ifdef CONFIG_PM
@@ -2251,7 +2251,7 @@ static int patch_ad1985_specific(struct snd_ac97 *ac97)
ARRAY_SIZE(snd_ac97_ad1985_controls));
}

-static struct snd_ac97_build_ops patch_ad1985_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1985_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1985_specific,
#ifdef CONFIG_PM
@@ -2543,7 +2543,7 @@ static int patch_ad1986_specific(struct snd_ac97 *ac97)
ARRAY_SIZE(snd_ac97_ad1985_controls));
}

-static struct snd_ac97_build_ops patch_ad1986_build_ops = {
+static const struct snd_ac97_build_ops patch_ad1986_build_ops = {
.build_post_spdif = patch_ad198x_post_spdif,
.build_specific = patch_ad1986_specific,
#ifdef CONFIG_PM
@@ -2648,7 +2648,7 @@ static int patch_alc650_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_alc650_ops = {
+static const struct snd_ac97_build_ops patch_alc650_ops = {
.build_specific = patch_alc650_specific,
.update_jacks = alc650_update_jacks
};
@@ -2800,7 +2800,7 @@ static int patch_alc655_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_alc655_ops = {
+static const struct snd_ac97_build_ops patch_alc655_ops = {
.build_specific = patch_alc655_specific,
.update_jacks = alc655_update_jacks
};
@@ -2912,7 +2912,7 @@ static int patch_alc850_specific(struct snd_ac97 *ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_alc850_ops = {
+static const struct snd_ac97_build_ops patch_alc850_ops = {
.build_specific = patch_alc850_specific,
.update_jacks = alc850_update_jacks
};
@@ -2974,7 +2974,7 @@ static int patch_cm9738_specific(struct snd_ac97 * ac97)
return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
}

-static struct snd_ac97_build_ops patch_cm9738_ops = {
+static const struct snd_ac97_build_ops patch_cm9738_ops = {
.build_specific = patch_cm9738_specific,
.update_jacks = cm9738_update_jacks
};
@@ -3065,7 +3065,7 @@ static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
}

-static struct snd_ac97_build_ops patch_cm9739_ops = {
+static const struct snd_ac97_build_ops patch_cm9739_ops = {
.build_specific = patch_cm9739_specific,
.build_post_spdif = patch_cm9739_post_spdif,
.update_jacks = cm9739_update_jacks
@@ -3239,7 +3239,7 @@ static int patch_cm9761_specific(struct snd_ac97 * ac97)
return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
}

-static struct snd_ac97_build_ops patch_cm9761_ops = {
+static const struct snd_ac97_build_ops patch_cm9761_ops = {
.build_specific = patch_cm9761_specific,
.build_post_spdif = patch_cm9761_post_spdif,
.update_jacks = cm9761_update_jacks
@@ -3335,7 +3335,7 @@ static int patch_cm9780_specific(struct snd_ac97 *ac97)
return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
}

-static struct snd_ac97_build_ops patch_cm9780_ops = {
+static const struct snd_ac97_build_ops patch_cm9780_ops = {
.build_specific = patch_cm9780_specific,
.build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
};
@@ -3455,7 +3455,7 @@ static int patch_vt1616_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_vt1616_ops = {
+static const struct snd_ac97_build_ops patch_vt1616_ops = {
.build_specific = patch_vt1616_specific
};

@@ -3809,7 +3809,7 @@ static int patch_it2646_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_it2646_ops = {
+static const struct snd_ac97_build_ops patch_it2646_ops = {
.build_specific = patch_it2646_specific,
.update_jacks = it2646_update_jacks
};
@@ -3843,7 +3843,7 @@ static int patch_si3036_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_si3036_ops = {
+static const struct snd_ac97_build_ops patch_si3036_ops = {
.build_specific = patch_si3036_specific,
};

@@ -3910,7 +3910,7 @@ static int patch_ucb1400_specific(struct snd_ac97 * ac97)
return 0;
}

-static struct snd_ac97_build_ops patch_ucb1400_ops = {
+static const struct snd_ac97_build_ops patch_ucb1400_ops = {
.build_specific = patch_ucb1400_specific,
};

2009-12-04 22:45:19

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct super_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
include/linux/fs.h | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2620a8c..4e23c70 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1553,30 +1553,30 @@ extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
unsigned long, loff_t *);

struct super_operations {
- struct inode *(*alloc_inode)(struct super_block *sb);
- void (*destroy_inode)(struct inode *);
-
- void (*dirty_inode) (struct inode *);
- int (*write_inode) (struct inode *, int);
- void (*drop_inode) (struct inode *);
- void (*delete_inode) (struct inode *);
- void (*put_super) (struct super_block *);
- void (*write_super) (struct super_block *);
- int (*sync_fs)(struct super_block *sb, int wait);
- int (*freeze_fs) (struct super_block *);
- int (*unfreeze_fs) (struct super_block *);
- int (*statfs) (struct dentry *, struct kstatfs *);
- int (*remount_fs) (struct super_block *, int *, char *);
- void (*clear_inode) (struct inode *);
- void (*umount_begin) (struct super_block *);
-
- int (*show_options)(struct seq_file *, struct vfsmount *);
- int (*show_stats)(struct seq_file *, struct vfsmount *);
+ struct inode *(* const alloc_inode)(struct super_block *sb);
+ void (* const destroy_inode)(struct inode *);
+
+ void (* const dirty_inode) (struct inode *);
+ int (* const write_inode) (struct inode *, int);
+ void (* const drop_inode) (struct inode *);
+ void (* const delete_inode) (struct inode *);
+ void (* const put_super) (struct super_block *);
+ void (* const write_super) (struct super_block *);
+ int (* const sync_fs)(struct super_block *sb, int wait);
+ int (* const freeze_fs) (struct super_block *);
+ int (* const unfreeze_fs) (struct super_block *);
+ int (* const statfs) (struct dentry *, struct kstatfs *);
+ int (* const remount_fs) (struct super_block *, int *, char *);
+ void (* const clear_inode) (struct inode *);
+ void (* const umount_begin) (struct super_block *);
+
+ int (* const show_options)(struct seq_file *, struct vfsmount *);
+ int (* const show_stats)(struct seq_file *, struct vfsmount *);
#ifdef CONFIG_QUOTA
- ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
- ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
+ ssize_t (* const quota_read)(struct super_block *, int, char *, size_t, loff_t);
+ ssize_t (* const quota_write)(struct super_block *, int, const char *, size_t, loff_t);
#endif
- int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
+ int (* const bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
};

/*

2009-12-04 22:48:32

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct sysfs_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/kernel/topology.c | 2 +-
arch/powerpc/kernel/cacheinfo.c | 2 +-
arch/sh/kernel/cpu/sh4/sq.c | 2 +-
arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +-
arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +-
block/blk-integrity.c | 2 +-
block/blk-sysfs.c | 2 +-
block/elevator.c | 2 +-
drivers/base/bus.c | 4 ++--
drivers/base/class.c | 2 +-
drivers/base/core.c | 2 +-
drivers/base/sys.c | 4 ++--
drivers/block/pktcdvd.c | 2 +-
drivers/cpufreq/cpufreq.c | 2 +-
drivers/cpuidle/sysfs.c | 4 ++--
drivers/dma/ioat/dma.c | 2 +-
drivers/dma/ioat/dma.h | 2 +-
drivers/edac/edac_device_sysfs.c | 6 +++---
drivers/edac/edac_mc_sysfs.c | 4 ++--
drivers/edac/edac_pci_sysfs.c | 4 ++--
drivers/firmware/edd.c | 2 +-
drivers/firmware/efivars.c | 2 +-
drivers/firmware/iscsi_ibft.c | 2 +-
drivers/firmware/memmap.c | 2 +-
drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
drivers/gpu/drm/ttm/ttm_memory.c | 2 +-
drivers/infiniband/core/cm.c | 2 +-
drivers/infiniband/core/sysfs.c | 2 +-
drivers/md/dm-sysfs.c | 2 +-
drivers/md/md.c | 4 ++--
drivers/net/ibmveth.c | 2 +-
drivers/net/iseries_veth.c | 4 ++--
drivers/parisc/pdc_stable.c | 2 +-
drivers/pci/hotplug/fakephp.c | 2 +-
drivers/pci/slot.c | 2 +-
drivers/uio/uio.c | 4 ++--
drivers/uwb/wlp/sysfs.c | 3 +--
drivers/xen/sys-hypervisor.c | 2 +-
fs/btrfs/sysfs.c | 4 ++--
fs/dlm/lockspace.c | 2 +-
fs/ext4/super.c | 2 +-
fs/gfs2/sys.c | 2 +-
fs/ocfs2/cluster/masklog.c | 2 +-
fs/sysfs/file.c | 8 ++++----
include/linux/kobject.h | 4 ++--
include/linux/sysfs.h | 4 ++--
kernel/params.c | 2 +-
lib/kobject.c | 2 +-
mm/slub.c | 2 +-
net/bridge/br_private.h | 2 +-
net/bridge/br_sysfs_if.c | 2 +-
samples/kobject/kset-example.c | 2 +-
52 files changed, 68 insertions(+), 69 deletions(-)

diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 8f06035..b3a5818 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
return ret;
}

-static struct sysfs_ops cache_sysfs_ops = {
+static const struct sysfs_ops cache_sysfs_ops = {
.show = cache_show
};

diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index bb37b1d..01fe9ce 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = {
&cache_assoc_attr,
};

-static struct sysfs_ops cache_index_ops = {
+static const struct sysfs_ops cache_index_ops = {
.show = cache_index_show,
};

diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 8a8a993..7b3079b 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -327,7 +327,7 @@ static struct attribute *sq_sysfs_attrs[] = {
NULL,
};

-static struct sysfs_ops sq_sysfs_ops = {
+static const struct sysfs_ops sq_sysfs_ops = {
.show = sq_sysfs_show,
.store = sq_sysfs_store,
};
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 804c40e..dc7f8a7 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -860,7 +860,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = show,
.store = store,
};
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 83a3d1f..cda932c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -388,7 +388,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops threshold_ops = {
+static const struct sysfs_ops threshold_ops = {
.show = show,
.store = store,
};
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 15c6308..96e83c2 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -278,7 +278,7 @@ static struct attribute *integrity_attrs[] = {
NULL,
};

-static struct sysfs_ops integrity_ops = {
+static const struct sysfs_ops integrity_ops = {
.show = &integrity_attr_show,
.store = &integrity_attr_store,
};
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 8a6d81a..dc3e40b 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -414,7 +414,7 @@ static void blk_release_queue(struct kobject *kobj)
kmem_cache_free(blk_requestq_cachep, q);
}

-static struct sysfs_ops queue_sysfs_ops = {
+static const struct sysfs_ops queue_sysfs_ops = {
.show = queue_attr_show,
.store = queue_attr_store,
};
diff --git a/block/elevator.c b/block/elevator.c
index a847046..75a1746 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -889,7 +889,7 @@ elv_attr_store(struct kobject *kobj, struct attribute *attr,
return error;
}

-static struct sysfs_ops elv_sysfs_ops = {
+static const struct sysfs_ops elv_sysfs_ops = {
.show = elv_attr_show,
.store = elv_attr_store,
};
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 63c143e..66ddfea 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -70,7 +70,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops driver_sysfs_ops = {
+static const struct sysfs_ops driver_sysfs_ops = {
.show = drv_attr_show,
.store = drv_attr_store,
};
@@ -115,7 +115,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops bus_sysfs_ops = {
+static const struct sysfs_ops bus_sysfs_ops = {
.show = bus_attr_show,
.store = bus_attr_store,
};
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 161746d..c2359c8 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -61,7 +61,7 @@ static void class_release(struct kobject *kobj)
"be careful\n", class->name);
}

-static struct sysfs_ops class_sysfs_ops = {
+static const struct sysfs_ops class_sysfs_ops = {
.show = class_attr_show,
.store = class_attr_store,
};
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6bee6af..35aeae5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -93,7 +93,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops dev_sysfs_ops = {
+static const struct sysfs_ops dev_sysfs_ops = {
.show = dev_attr_show,
.store = dev_attr_store,
};
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 0d90390..dd710ca 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -54,7 +54,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = sysdev_show,
.store = sysdev_store,
};
@@ -104,7 +104,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops sysfs_class_ops = {
+static const struct sysfs_ops sysfs_class_ops = {
.show = sysdev_class_show,
.store = sysdev_class_store,
};
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 2ddf03a..44eab68 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -284,7 +284,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
return len;
}

-static struct sysfs_ops kobj_pkt_ops = {
+static const struct sysfs_ops kobj_pkt_ops = {
.show = kobj_pkt_show,
.store = kobj_pkt_store
};
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index ff57c40..76da29f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -750,7 +750,7 @@ static void cpufreq_sysfs_release(struct kobject *kobj)
complete(&policy->kobj_unregister);
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = show,
.store = store,
};
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 97b0038..aaaa360 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -191,7 +191,7 @@ static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr,
return ret;
}

-static struct sysfs_ops cpuidle_sysfs_ops = {
+static const struct sysfs_ops cpuidle_sysfs_ops = {
.show = cpuidle_show,
.store = cpuidle_store,
};
@@ -277,7 +277,7 @@ static ssize_t cpuidle_state_show(struct kobject * kobj,
return ret;
}

-static struct sysfs_ops cpuidle_state_sysfs_ops = {
+static const struct sysfs_ops cpuidle_state_sysfs_ops = {
.show = cpuidle_state_show,
};

diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index c524d36..fc2d0b6 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -1146,7 +1146,7 @@ ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
return entry->show(&chan->common, page);
}

-struct sysfs_ops ioat_sysfs_ops = {
+const struct sysfs_ops ioat_sysfs_ops = {
.show = ioat_attr_show,
};

diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index 45edde9..c72e7fe 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -329,7 +329,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
unsigned long *phys_complete);
void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
void ioat_kobject_del(struct ioatdma_device *device);
-extern struct sysfs_ops ioat_sysfs_ops;
+extern const struct sysfs_ops ioat_sysfs_ops;
extern struct ioat_sysfs_entry ioat_version_attr;
extern struct ioat_sysfs_entry ioat_cap_attr;
#endif /* IOATDMA_H */
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 5376457..5fdedbc 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -137,7 +137,7 @@ static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
}

/* edac_dev file operations for an 'ctl_info' */
-static struct sysfs_ops device_ctl_info_ops = {
+static const struct sysfs_ops device_ctl_info_ops = {
.show = edac_dev_ctl_info_show,
.store = edac_dev_ctl_info_store
};
@@ -373,7 +373,7 @@ static ssize_t edac_dev_instance_store(struct kobject *kobj,
}

/* edac_dev file operations for an 'instance' */
-static struct sysfs_ops device_instance_ops = {
+static const struct sysfs_ops device_instance_ops = {
.show = edac_dev_instance_show,
.store = edac_dev_instance_store
};
@@ -476,7 +476,7 @@ static ssize_t edac_dev_block_store(struct kobject *kobj,
}

/* edac_dev file operations for a 'block' */
-static struct sysfs_ops device_block_ops = {
+static const struct sysfs_ops device_block_ops = {
.show = edac_dev_block_show,
.store = edac_dev_block_store
};
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index e1d4ce0..88840e9 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -245,7 +245,7 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops csrowfs_ops = {
+static const struct sysfs_ops csrowfs_ops = {
.show = csrowdev_show,
.store = csrowdev_store
};
@@ -575,7 +575,7 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
}

/* Intermediate show/store table */
-static struct sysfs_ops mci_ops = {
+static const struct sysfs_ops mci_ops = {
.show = mcidev_show,
.store = mcidev_store
};
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 422728c..79217da 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -121,7 +121,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj,
}

/* fs_ops table */
-static struct sysfs_ops pci_instance_ops = {
+static const struct sysfs_ops pci_instance_ops = {
.show = edac_pci_instance_show,
.store = edac_pci_instance_store
};
@@ -261,7 +261,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
return -EIO;
}

-static struct sysfs_ops edac_pci_sysfs_ops = {
+static const struct sysfs_ops edac_pci_sysfs_ops = {
.show = edac_pci_dev_show,
.store = edac_pci_dev_store
};
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 9e4f59d..110e24e 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -122,7 +122,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
return ret;
}

-static struct sysfs_ops edd_attr_ops = {
+static const struct sysfs_ops edd_attr_ops = {
.show = edd_attr_show,
};

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index f4f709d..082f06e 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -362,7 +362,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops efivar_attr_ops = {
+static const struct sysfs_ops efivar_attr_ops = {
.show = efivar_attr_show,
.store = efivar_attr_store,
};
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 051d1eb..0a5d4e7 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -525,7 +525,7 @@ static ssize_t ibft_show_attribute(struct kobject *kobj,
return ret;
}

-static struct sysfs_ops ibft_attr_ops = {
+static const struct sysfs_ops ibft_attr_ops = {
.show = ibft_show_attribute,
};

diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 56f9234..8c58c7b 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -74,7 +74,7 @@ static struct attribute *def_attrs[] = {
NULL
};

-static struct sysfs_ops memmap_attr_ops = {
+static const struct sysfs_ops memmap_attr_ops = {
.show = memmap_attr_show,
};

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 87c0625..d9a23ef 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -67,7 +67,7 @@ static struct attribute *ttm_bo_global_attrs[] = {
NULL
};

-static struct sysfs_ops ttm_bo_global_ops = {
+static const struct sysfs_ops ttm_bo_global_ops = {
.show = &ttm_bo_global_show
};

diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 072c281..d8ef483 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -152,7 +152,7 @@ static struct attribute *ttm_mem_zone_attrs[] = {
NULL
};

-static struct sysfs_ops ttm_mem_zone_ops = {
+static const struct sysfs_ops ttm_mem_zone_ops = {
.show = &ttm_mem_zone_show,
.store = &ttm_mem_zone_store
};
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 5130fc5..764787e 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3597,7 +3597,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
atomic_long_read(&group->counter[cm_attr->index]));
}

-static struct sysfs_ops cm_counter_ops = {
+static const struct sysfs_ops cm_counter_ops = {
.show = cm_show_counter
};

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 158a214..1558bb7 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -79,7 +79,7 @@ static ssize_t port_attr_show(struct kobject *kobj,
return port_attr->show(p, port_attr, buf);
}

-static struct sysfs_ops port_sysfs_ops = {
+static const struct sysfs_ops port_sysfs_ops = {
.show = port_attr_show
};

diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c
index 4b04590..13a77b2 100644
--- a/drivers/md/dm-sysfs.c
+++ b/drivers/md/dm-sysfs.c
@@ -75,7 +75,7 @@ static struct attribute *dm_attrs[] = {
NULL,
};

-static struct sysfs_ops dm_sysfs_ops = {
+static const struct sysfs_ops dm_sysfs_ops = {
.show = dm_attr_show,
};

diff --git a/drivers/md/md.c b/drivers/md/md.c
index b182f86..431d54d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2505,7 +2505,7 @@ static void rdev_free(struct kobject *ko)
mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj);
kfree(rdev);
}
-static struct sysfs_ops rdev_sysfs_ops = {
+static const struct sysfs_ops rdev_sysfs_ops = {
.show = rdev_attr_show,
.store = rdev_attr_store,
};
@@ -3875,7 +3875,7 @@ static void md_free(struct kobject *ko)
kfree(mddev);
}

-static struct sysfs_ops md_sysfs_ops = {
+static const struct sysfs_ops md_sysfs_ops = {
.show = md_attr_show,
.store = md_attr_store,
};
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 5862282..7cce8cb 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1577,7 +1577,7 @@ static struct attribute * veth_pool_attrs[] = {
NULL,
};

-static struct sysfs_ops veth_pool_ops = {
+static const struct sysfs_ops veth_pool_ops = {
.show = veth_pool_show,
.store = veth_pool_store,
};
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index aa7286b..a61394f 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -384,7 +384,7 @@ static struct attribute *veth_cnx_default_attrs[] = {
NULL
};

-static struct sysfs_ops veth_cnx_sysfs_ops = {
+static const struct sysfs_ops veth_cnx_sysfs_ops = {
.show = veth_cnx_attribute_show
};

@@ -441,7 +441,7 @@ static struct attribute *veth_port_default_attrs[] = {
NULL
};

-static struct sysfs_ops veth_port_sysfs_ops = {
+static const struct sysfs_ops veth_port_sysfs_ops = {
.show = veth_port_attribute_show
};

diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 13a64bc..ad62835 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -481,7 +481,7 @@ pdcspath_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops pdcspath_attr_ops = {
+static const struct sysfs_ops pdcspath_attr_ops = {
.show = pdcspath_attr_show,
.store = pdcspath_attr_store,
};
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 6151389..0a894ef 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -73,7 +73,7 @@ static void legacy_release(struct kobject *kobj)
}

static struct kobj_type legacy_ktype = {
- .sysfs_ops = &(struct sysfs_ops){
+ .sysfs_ops = &(const struct sysfs_ops){
.store = legacy_store, .show = legacy_show
},
.release = &legacy_release,
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 8c02b6c..5584d8e 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -29,7 +29,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj,
return attribute->store ? attribute->store(slot, buf, len) : -EIO;
}

-static struct sysfs_ops pci_slot_sysfs_ops = {
+static const struct sysfs_ops pci_slot_sysfs_ops = {
.show = pci_slot_attr_show,
.store = pci_slot_attr_store,
};
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index e941367..4de382a 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -129,7 +129,7 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
return entry->show(mem, buf);
}

-static struct sysfs_ops map_sysfs_ops = {
+static const struct sysfs_ops map_sysfs_ops = {
.show = map_type_show,
};

@@ -217,7 +217,7 @@ static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr,
return entry->show(port, buf);
}

-static struct sysfs_ops portio_sysfs_ops = {
+static const struct sysfs_ops portio_sysfs_ops = {
.show = portio_type_show,
};

diff --git a/drivers/uwb/wlp/sysfs.c b/drivers/uwb/wlp/sysfs.c
index 0370399..6627c94 100644
--- a/drivers/uwb/wlp/sysfs.c
+++ b/drivers/uwb/wlp/sysfs.c
@@ -615,8 +615,7 @@ ssize_t wlp_wss_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static
-struct sysfs_ops wss_sysfs_ops = {
+static const struct sysfs_ops wss_sysfs_ops = {
.show = wlp_wss_attr_show,
.store = wlp_wss_attr_store,
};
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
index 88a60e0..6783cc2 100644
--- a/drivers/xen/sys-hypervisor.c
+++ b/drivers/xen/sys-hypervisor.c
@@ -425,7 +425,7 @@ static ssize_t hyp_sysfs_store(struct kobject *kobj,
return 0;
}

-static struct sysfs_ops hyp_sysfs_ops = {
+static const struct sysfs_ops hyp_sysfs_ops = {
.show = hyp_sysfs_show,
.store = hyp_sysfs_store,
};
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index a240b6f..4ce16ef 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -164,12 +164,12 @@ static void btrfs_root_release(struct kobject *kobj)
complete(&root->kobj_unregister);
}

-static struct sysfs_ops btrfs_super_attr_ops = {
+static const struct sysfs_ops btrfs_super_attr_ops = {
.show = btrfs_super_attr_show,
.store = btrfs_super_attr_store,
};

-static struct sysfs_ops btrfs_root_attr_ops = {
+static const struct sysfs_ops btrfs_root_attr_ops = {
.show = btrfs_root_attr_show,
.store = btrfs_root_attr_store,
};
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index d489fcc..5b0bd1e 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -148,7 +148,7 @@ static void lockspace_kobj_release(struct kobject *k)
kfree(ls);
}

-static struct sysfs_ops dlm_attr_ops = {
+static const struct sysfs_ops dlm_attr_ops = {
.show = dlm_attr_show,
.store = dlm_attr_store,
};
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d4ca92a..b0594f3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2251,7 +2251,7 @@ static void ext4_sb_release(struct kobject *kobj)
}


-static struct sysfs_ops ext4_attr_ops = {
+static const struct sysfs_ops ext4_attr_ops = {
.show = ext4_attr_show,
.store = ext4_attr_store,
};
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 4463297..cc946e8 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -49,7 +49,7 @@ static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
return a->store ? a->store(sdp, buf, len) : len;
}

-static struct sysfs_ops gfs2_attr_ops = {
+static const struct sysfs_ops gfs2_attr_ops = {
.show = gfs2_attr_show,
.store = gfs2_attr_store,
};
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index 1cd2934..880b5d2 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -135,7 +135,7 @@ static ssize_t mlog_store(struct kobject *obj, struct attribute *attr,
return mlog_mask_store(mlog_attr->mask, buf, count);
}

-static struct sysfs_ops mlog_attr_ops = {
+static const struct sysfs_ops mlog_attr_ops = {
.show = mlog_show,
.store = mlog_store,
};
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index f5ea468..b59b2e4 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -53,7 +53,7 @@ struct sysfs_buffer {
size_t count;
loff_t pos;
char * page;
- struct sysfs_ops * ops;
+ const struct sysfs_ops * ops;
struct mutex mutex;
int needs_read_fill;
int event;
@@ -75,7 +75,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
{
struct sysfs_dirent *attr_sd = dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
- struct sysfs_ops * ops = buffer->ops;
+ const struct sysfs_ops * ops = buffer->ops;
int ret = 0;
ssize_t count;

@@ -199,7 +199,7 @@ flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t
{
struct sysfs_dirent *attr_sd = dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
- struct sysfs_ops * ops = buffer->ops;
+ const struct sysfs_ops * ops = buffer->ops;
int rc;

/* need attr_sd for attr and ops, its parent for kobj */
@@ -335,7 +335,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
struct sysfs_buffer *buffer;
- struct sysfs_ops *ops;
+ const struct sysfs_ops *ops;
int error = -EACCES;
char *p;

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 58ae8e0..072cee4 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -106,7 +106,7 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);

struct kobj_type {
void (*release)(struct kobject *kobj);
- struct sysfs_ops *sysfs_ops;
+ const struct sysfs_ops *sysfs_ops;
struct attribute **default_attrs;
};

@@ -132,7 +132,7 @@ struct kobj_attribute {
const char *buf, size_t count);
};

-extern struct sysfs_ops kobj_sysfs_ops;
+extern const struct sysfs_ops kobj_sysfs_ops;

/**
* struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 9d68fed..71f02cc 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -75,8 +75,8 @@ struct bin_attribute {
};

struct sysfs_ops {
- ssize_t (*show)(struct kobject *, struct attribute *,char *);
- ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
+ ssize_t (* const show)(struct kobject *, struct attribute *,char *);
+ ssize_t (* const store)(struct kobject *,struct attribute *,const char *, size_t);
};

struct sysfs_dirent;
diff --git a/kernel/params.c b/kernel/params.c
index d656c27..8b060d0 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -725,7 +725,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
return ret;
}

-static struct sysfs_ops module_sysfs_ops = {
+static const struct sysfs_ops module_sysfs_ops = {
.show = module_attr_show,
.store = module_attr_store,
};
diff --git a/lib/kobject.c b/lib/kobject.c
index b512b74..6567393 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -700,7 +700,7 @@ static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-struct sysfs_ops kobj_sysfs_ops = {
+const struct sysfs_ops kobj_sysfs_ops = {
.show = kobj_attr_show,
.store = kobj_attr_store,
};
diff --git a/mm/slub.c b/mm/slub.c
index 4996fc7..7c047ba 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4503,7 +4503,7 @@ static void kmem_cache_release(struct kobject *kobj)
kfree(s);
}

-static struct sysfs_ops slab_sysfs_ops = {
+static const struct sysfs_ops slab_sysfs_ops = {
.show = slab_attr_show,
.store = slab_attr_store,
};
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 2114e45..c53bdd9 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -254,7 +254,7 @@ extern void br_ifinfo_notify(int event, struct net_bridge_port *port);

#ifdef CONFIG_SYSFS
/* br_sysfs_if.c */
-extern struct sysfs_ops brport_sysfs_ops;
+extern const struct sysfs_ops brport_sysfs_ops;
extern int br_sysfs_addif(struct net_bridge_port *p);

/* br_sysfs_br.c */
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 820643a..ce77fb3 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -220,7 +220,7 @@ static ssize_t brport_store(struct kobject * kobj,
return ret;
}

-struct sysfs_ops brport_sysfs_ops = {
+const struct sysfs_ops brport_sysfs_ops = {
.show = brport_show,
.store = brport_store,
};
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
index 45b7d56..19e828c 100644
--- a/samples/kobject/kset-example.c
+++ b/samples/kobject/kset-example.c
@@ -87,7 +87,7 @@ static ssize_t foo_attr_store(struct kobject *kobj,
}

/* Our custom sysfs_ops that we will associate with our ktype later on */
-static struct sysfs_ops foo_sysfs_ops = {
+static const struct sysfs_ops foo_sysfs_ops = {
.show = foo_attr_show,
.store = foo_attr_store,
};

2009-12-04 22:48:39

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 30/31] Constify struct usb_mon_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct usb_mon_operations.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/usb/core/hcd.c | 4 ++--
drivers/usb/core/hcd.h | 10 +++++-----
drivers/usb/mon/mon_main.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 34de475..cfcb4fb 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2216,7 +2216,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);

#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)

-struct usb_mon_operations *mon_ops;
+const struct usb_mon_operations *mon_ops;

/*
* The registration is unlocked.
@@ -2226,7 +2226,7 @@ struct usb_mon_operations *mon_ops;
* symbols from usbcore, usbcore gets referenced and cannot be unloaded first.
*/

-int usb_mon_register (struct usb_mon_operations *ops)
+int usb_mon_register (const struct usb_mon_operations *ops)
{

if (mon_ops)
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 79782a1..04bf5ea 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -486,13 +486,13 @@ static inline void usbfs_cleanup(void) { }
#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)

struct usb_mon_operations {
- void (*urb_submit)(struct usb_bus *bus, struct urb *urb);
- void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err);
- void (*urb_complete)(struct usb_bus *bus, struct urb *urb, int status);
+ void (* const urb_submit)(struct usb_bus *bus, struct urb *urb);
+ void (* const urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err);
+ void (* const urb_complete)(struct usb_bus *bus, struct urb *urb, int status);
/* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
};

-extern struct usb_mon_operations *mon_ops;
+extern const struct usb_mon_operations *mon_ops;

static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb)
{
@@ -514,7 +514,7 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
(*mon_ops->urb_complete)(bus, urb, status);
}

-int usb_mon_register(struct usb_mon_operations *ops);
+int usb_mon_register(const struct usb_mon_operations *ops);
void usb_mon_deregister(void);

#else
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index e0c2db3..bd8cb66 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -238,7 +238,7 @@ static struct notifier_block mon_nb = {
/*
* Ops
*/
-static struct usb_mon_operations mon_ops_0 = {
+static const struct usb_mon_operations mon_ops_0 = {
.urb_submit = mon_submit,
.urb_submit_error = mon_submit_error,
.urb_complete = mon_complete,

2009-12-04 22:49:59

by Emese Revfy

[permalink] [raw]
Subject: [PATCH 31/31] Constify struct wd_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct wd_ops with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/x86/kernel/cpu/perfctr-watchdog.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index fab786f..2324cbc 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -30,11 +30,11 @@ struct nmi_watchdog_ctlblk {

/* Interface defining a CPU specific perfctr watchdog */
struct wd_ops {
- int (*reserve)(void);
- void (*unreserve)(void);
- int (*setup)(unsigned nmi_hz);
- void (*rearm)(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz);
- void (*stop)(void);
+ int (* const reserve)(void);
+ void (* const unreserve)(void);
+ int (* const setup)(unsigned nmi_hz);
+ void (* const rearm)(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz);
+ void (* const stop)(void);
unsigned perfctr;
unsigned evntsel;
u64 checkbit;
@@ -645,6 +645,7 @@ static const struct wd_ops p4_wd_ops = {
#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
#define ARCH_PERFMON_NMI_EVENT_UMASK ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK

+/* cannot be const */
static struct wd_ops intel_arch_wd_ops;

static int setup_intel_arch_watchdog(unsigned nmi_hz)
@@ -697,6 +698,7 @@ static int setup_intel_arch_watchdog(unsigned nmi_hz)
return 1;
}

+/* cannot be const */
static struct wd_ops intel_arch_wd_ops __read_mostly = {
.reserve = single_msr_reserve,
.unreserve = single_msr_unreserve,

2009-12-04 22:59:48

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

Added [email protected] to CC.

> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> arch/ia64/kernel/topology.c | 2 +-
> arch/powerpc/kernel/cacheinfo.c | 2 +-
> arch/sh/kernel/cpu/sh4/sq.c | 2 +-
> arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +-
> arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +-
> block/blk-integrity.c | 2 +-
> block/blk-sysfs.c | 2 +-
> block/elevator.c | 2 +-
> drivers/base/bus.c | 4 ++--
> drivers/base/class.c | 2 +-
> drivers/base/core.c | 2 +-
> drivers/base/sys.c | 4 ++--
> drivers/block/pktcdvd.c | 2 +-
> drivers/cpufreq/cpufreq.c | 2 +-
> drivers/cpuidle/sysfs.c | 4 ++--
> drivers/dma/ioat/dma.c | 2 +-
> drivers/dma/ioat/dma.h | 2 +-
> drivers/edac/edac_device_sysfs.c | 6 +++---
> drivers/edac/edac_mc_sysfs.c | 4 ++--
> drivers/edac/edac_pci_sysfs.c | 4 ++--
> drivers/firmware/edd.c | 2 +-
> drivers/firmware/efivars.c | 2 +-
> drivers/firmware/iscsi_ibft.c | 2 +-
> drivers/firmware/memmap.c | 2 +-
> drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
> drivers/gpu/drm/ttm/ttm_memory.c | 2 +-
> drivers/infiniband/core/cm.c | 2 +-
> drivers/infiniband/core/sysfs.c | 2 +-
> drivers/md/dm-sysfs.c | 2 +-
> drivers/md/md.c | 4 ++--
> drivers/net/ibmveth.c | 2 +-
> drivers/net/iseries_veth.c | 4 ++--
> drivers/parisc/pdc_stable.c | 2 +-
> drivers/pci/hotplug/fakephp.c | 2 +-
> drivers/pci/slot.c | 2 +-
> drivers/uio/uio.c | 4 ++--
> drivers/uwb/wlp/sysfs.c | 3 +--
> drivers/xen/sys-hypervisor.c | 2 +-
> fs/btrfs/sysfs.c | 4 ++--
> fs/dlm/lockspace.c | 2 +-
> fs/ext4/super.c | 2 +-
> fs/gfs2/sys.c | 2 +-
> fs/ocfs2/cluster/masklog.c | 2 +-
> fs/sysfs/file.c | 8 ++++----
> include/linux/kobject.h | 4 ++--
> include/linux/sysfs.h | 4 ++--
> kernel/params.c | 2 +-
> lib/kobject.c | 2 +-
> mm/slub.c | 2 +-
> net/bridge/br_private.h | 2 +-
> net/bridge/br_sysfs_if.c | 2 +-
> samples/kobject/kset-example.c | 2 +-
> 52 files changed, 68 insertions(+), 69 deletions(-)
>
> diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
> index 8f06035..b3a5818 100644
> --- a/arch/ia64/kernel/topology.c
> +++ b/arch/ia64/kernel/topology.c
> @@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
> return ret;
> }
>
> -static struct sysfs_ops cache_sysfs_ops = {
> +static const struct sysfs_ops cache_sysfs_ops = {
> .show = cache_show
> };
>
> diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
> index bb37b1d..01fe9ce 100644
> --- a/arch/powerpc/kernel/cacheinfo.c
> +++ b/arch/powerpc/kernel/cacheinfo.c
> @@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = {
> &cache_assoc_attr,
> };
>
> -static struct sysfs_ops cache_index_ops = {
> +static const struct sysfs_ops cache_index_ops = {
> .show = cache_index_show,
> };
>
> diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
> index 8a8a993..7b3079b 100644
> --- a/arch/sh/kernel/cpu/sh4/sq.c
> +++ b/arch/sh/kernel/cpu/sh4/sq.c
> @@ -327,7 +327,7 @@ static struct attribute *sq_sysfs_attrs[] = {
> NULL,
> };
>
> -static struct sysfs_ops sq_sysfs_ops = {
> +static const struct sysfs_ops sq_sysfs_ops = {
> .show = sq_sysfs_show,
> .store = sq_sysfs_store,
> };
> diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
> index 804c40e..dc7f8a7 100644
> --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
> +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
> @@ -860,7 +860,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops sysfs_ops = {
> +static const struct sysfs_ops sysfs_ops = {
> .show = show,
> .store = store,
> };
> diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
> index 83a3d1f..cda932c 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
> @@ -388,7 +388,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops threshold_ops = {
> +static const struct sysfs_ops threshold_ops = {
> .show = show,
> .store = store,
> };
> diff --git a/block/blk-integrity.c b/block/blk-integrity.c
> index 15c6308..96e83c2 100644
> --- a/block/blk-integrity.c
> +++ b/block/blk-integrity.c
> @@ -278,7 +278,7 @@ static struct attribute *integrity_attrs[] = {
> NULL,
> };
>
> -static struct sysfs_ops integrity_ops = {
> +static const struct sysfs_ops integrity_ops = {
> .show = &integrity_attr_show,
> .store = &integrity_attr_store,
> };
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 8a6d81a..dc3e40b 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -414,7 +414,7 @@ static void blk_release_queue(struct kobject *kobj)
> kmem_cache_free(blk_requestq_cachep, q);
> }
>
> -static struct sysfs_ops queue_sysfs_ops = {
> +static const struct sysfs_ops queue_sysfs_ops = {
> .show = queue_attr_show,
> .store = queue_attr_store,
> };
> diff --git a/block/elevator.c b/block/elevator.c
> index a847046..75a1746 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -889,7 +889,7 @@ elv_attr_store(struct kobject *kobj, struct attribute *attr,
> return error;
> }
>
> -static struct sysfs_ops elv_sysfs_ops = {
> +static const struct sysfs_ops elv_sysfs_ops = {
> .show = elv_attr_show,
> .store = elv_attr_store,
> };
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 63c143e..66ddfea 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -70,7 +70,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops driver_sysfs_ops = {
> +static const struct sysfs_ops driver_sysfs_ops = {
> .show = drv_attr_show,
> .store = drv_attr_store,
> };
> @@ -115,7 +115,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops bus_sysfs_ops = {
> +static const struct sysfs_ops bus_sysfs_ops = {
> .show = bus_attr_show,
> .store = bus_attr_store,
> };
> diff --git a/drivers/base/class.c b/drivers/base/class.c
> index 161746d..c2359c8 100644
> --- a/drivers/base/class.c
> +++ b/drivers/base/class.c
> @@ -61,7 +61,7 @@ static void class_release(struct kobject *kobj)
> "be careful\n", class->name);
> }
>
> -static struct sysfs_ops class_sysfs_ops = {
> +static const struct sysfs_ops class_sysfs_ops = {
> .show = class_attr_show,
> .store = class_attr_store,
> };
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 6bee6af..35aeae5 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -93,7 +93,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops dev_sysfs_ops = {
> +static const struct sysfs_ops dev_sysfs_ops = {
> .show = dev_attr_show,
> .store = dev_attr_store,
> };
> diff --git a/drivers/base/sys.c b/drivers/base/sys.c
> index 0d90390..dd710ca 100644
> --- a/drivers/base/sys.c
> +++ b/drivers/base/sys.c
> @@ -54,7 +54,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr,
> return -EIO;
> }
>
> -static struct sysfs_ops sysfs_ops = {
> +static const struct sysfs_ops sysfs_ops = {
> .show = sysdev_show,
> .store = sysdev_store,
> };
> @@ -104,7 +104,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
> return -EIO;
> }
>
> -static struct sysfs_ops sysfs_class_ops = {
> +static const struct sysfs_ops sysfs_class_ops = {
> .show = sysdev_class_show,
> .store = sysdev_class_store,
> };
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index 2ddf03a..44eab68 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -284,7 +284,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
> return len;
> }
>
> -static struct sysfs_ops kobj_pkt_ops = {
> +static const struct sysfs_ops kobj_pkt_ops = {
> .show = kobj_pkt_show,
> .store = kobj_pkt_store
> };
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index ff57c40..76da29f 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -750,7 +750,7 @@ static void cpufreq_sysfs_release(struct kobject *kobj)
> complete(&policy->kobj_unregister);
> }
>
> -static struct sysfs_ops sysfs_ops = {
> +static const struct sysfs_ops sysfs_ops = {
> .show = show,
> .store = store,
> };
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> index 97b0038..aaaa360 100644
> --- a/drivers/cpuidle/sysfs.c
> +++ b/drivers/cpuidle/sysfs.c
> @@ -191,7 +191,7 @@ static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr,
> return ret;
> }
>
> -static struct sysfs_ops cpuidle_sysfs_ops = {
> +static const struct sysfs_ops cpuidle_sysfs_ops = {
> .show = cpuidle_show,
> .store = cpuidle_store,
> };
> @@ -277,7 +277,7 @@ static ssize_t cpuidle_state_show(struct kobject * kobj,
> return ret;
> }
>
> -static struct sysfs_ops cpuidle_state_sysfs_ops = {
> +static const struct sysfs_ops cpuidle_state_sysfs_ops = {
> .show = cpuidle_state_show,
> };
>
> diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
> index c524d36..fc2d0b6 100644
> --- a/drivers/dma/ioat/dma.c
> +++ b/drivers/dma/ioat/dma.c
> @@ -1146,7 +1146,7 @@ ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
> return entry->show(&chan->common, page);
> }
>
> -struct sysfs_ops ioat_sysfs_ops = {
> +const struct sysfs_ops ioat_sysfs_ops = {
> .show = ioat_attr_show,
> };
>
> diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
> index 45edde9..c72e7fe 100644
> --- a/drivers/dma/ioat/dma.h
> +++ b/drivers/dma/ioat/dma.h
> @@ -329,7 +329,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
> unsigned long *phys_complete);
> void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
> void ioat_kobject_del(struct ioatdma_device *device);
> -extern struct sysfs_ops ioat_sysfs_ops;
> +extern const struct sysfs_ops ioat_sysfs_ops;
> extern struct ioat_sysfs_entry ioat_version_attr;
> extern struct ioat_sysfs_entry ioat_cap_attr;
> #endif /* IOATDMA_H */
> diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
> index 5376457..5fdedbc 100644
> --- a/drivers/edac/edac_device_sysfs.c
> +++ b/drivers/edac/edac_device_sysfs.c
> @@ -137,7 +137,7 @@ static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
> }
>
> /* edac_dev file operations for an 'ctl_info' */
> -static struct sysfs_ops device_ctl_info_ops = {
> +static const struct sysfs_ops device_ctl_info_ops = {
> .show = edac_dev_ctl_info_show,
> .store = edac_dev_ctl_info_store
> };
> @@ -373,7 +373,7 @@ static ssize_t edac_dev_instance_store(struct kobject *kobj,
> }
>
> /* edac_dev file operations for an 'instance' */
> -static struct sysfs_ops device_instance_ops = {
> +static const struct sysfs_ops device_instance_ops = {
> .show = edac_dev_instance_show,
> .store = edac_dev_instance_store
> };
> @@ -476,7 +476,7 @@ static ssize_t edac_dev_block_store(struct kobject *kobj,
> }
>
> /* edac_dev file operations for a 'block' */
> -static struct sysfs_ops device_block_ops = {
> +static const struct sysfs_ops device_block_ops = {
> .show = edac_dev_block_show,
> .store = edac_dev_block_store
> };
> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
> index e1d4ce0..88840e9 100644
> --- a/drivers/edac/edac_mc_sysfs.c
> +++ b/drivers/edac/edac_mc_sysfs.c
> @@ -245,7 +245,7 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
> return -EIO;
> }
>
> -static struct sysfs_ops csrowfs_ops = {
> +static const struct sysfs_ops csrowfs_ops = {
> .show = csrowdev_show,
> .store = csrowdev_store
> };
> @@ -575,7 +575,7 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
> }
>
> /* Intermediate show/store table */
> -static struct sysfs_ops mci_ops = {
> +static const struct sysfs_ops mci_ops = {
> .show = mcidev_show,
> .store = mcidev_store
> };
> diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
> index 422728c..79217da 100644
> --- a/drivers/edac/edac_pci_sysfs.c
> +++ b/drivers/edac/edac_pci_sysfs.c
> @@ -121,7 +121,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj,
> }
>
> /* fs_ops table */
> -static struct sysfs_ops pci_instance_ops = {
> +static const struct sysfs_ops pci_instance_ops = {
> .show = edac_pci_instance_show,
> .store = edac_pci_instance_store
> };
> @@ -261,7 +261,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
> return -EIO;
> }
>
> -static struct sysfs_ops edac_pci_sysfs_ops = {
> +static const struct sysfs_ops edac_pci_sysfs_ops = {
> .show = edac_pci_dev_show,
> .store = edac_pci_dev_store
> };
> diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
> index 9e4f59d..110e24e 100644
> --- a/drivers/firmware/edd.c
> +++ b/drivers/firmware/edd.c
> @@ -122,7 +122,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
> return ret;
> }
>
> -static struct sysfs_ops edd_attr_ops = {
> +static const struct sysfs_ops edd_attr_ops = {
> .show = edd_attr_show,
> };
>
> diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
> index f4f709d..082f06e 100644
> --- a/drivers/firmware/efivars.c
> +++ b/drivers/firmware/efivars.c
> @@ -362,7 +362,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops efivar_attr_ops = {
> +static const struct sysfs_ops efivar_attr_ops = {
> .show = efivar_attr_show,
> .store = efivar_attr_store,
> };
> diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
> index 051d1eb..0a5d4e7 100644
> --- a/drivers/firmware/iscsi_ibft.c
> +++ b/drivers/firmware/iscsi_ibft.c
> @@ -525,7 +525,7 @@ static ssize_t ibft_show_attribute(struct kobject *kobj,
> return ret;
> }
>
> -static struct sysfs_ops ibft_attr_ops = {
> +static const struct sysfs_ops ibft_attr_ops = {
> .show = ibft_show_attribute,
> };
>
> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
> index 56f9234..8c58c7b 100644
> --- a/drivers/firmware/memmap.c
> +++ b/drivers/firmware/memmap.c
> @@ -74,7 +74,7 @@ static struct attribute *def_attrs[] = {
> NULL
> };
>
> -static struct sysfs_ops memmap_attr_ops = {
> +static const struct sysfs_ops memmap_attr_ops = {
> .show = memmap_attr_show,
> };
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 87c0625..d9a23ef 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -67,7 +67,7 @@ static struct attribute *ttm_bo_global_attrs[] = {
> NULL
> };
>
> -static struct sysfs_ops ttm_bo_global_ops = {
> +static const struct sysfs_ops ttm_bo_global_ops = {
> .show = &ttm_bo_global_show
> };
>
> diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 072c281..d8ef483 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -152,7 +152,7 @@ static struct attribute *ttm_mem_zone_attrs[] = {
> NULL
> };
>
> -static struct sysfs_ops ttm_mem_zone_ops = {
> +static const struct sysfs_ops ttm_mem_zone_ops = {
> .show = &ttm_mem_zone_show,
> .store = &ttm_mem_zone_store
> };
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index 5130fc5..764787e 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -3597,7 +3597,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
> atomic_long_read(&group->counter[cm_attr->index]));
> }
>
> -static struct sysfs_ops cm_counter_ops = {
> +static const struct sysfs_ops cm_counter_ops = {
> .show = cm_show_counter
> };
>
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index 158a214..1558bb7 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -79,7 +79,7 @@ static ssize_t port_attr_show(struct kobject *kobj,
> return port_attr->show(p, port_attr, buf);
> }
>
> -static struct sysfs_ops port_sysfs_ops = {
> +static const struct sysfs_ops port_sysfs_ops = {
> .show = port_attr_show
> };
>
> diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c
> index 4b04590..13a77b2 100644
> --- a/drivers/md/dm-sysfs.c
> +++ b/drivers/md/dm-sysfs.c
> @@ -75,7 +75,7 @@ static struct attribute *dm_attrs[] = {
> NULL,
> };
>
> -static struct sysfs_ops dm_sysfs_ops = {
> +static const struct sysfs_ops dm_sysfs_ops = {
> .show = dm_attr_show,
> };
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index b182f86..431d54d 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2505,7 +2505,7 @@ static void rdev_free(struct kobject *ko)
> mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj);
> kfree(rdev);
> }
> -static struct sysfs_ops rdev_sysfs_ops = {
> +static const struct sysfs_ops rdev_sysfs_ops = {
> .show = rdev_attr_show,
> .store = rdev_attr_store,
> };
> @@ -3875,7 +3875,7 @@ static void md_free(struct kobject *ko)
> kfree(mddev);
> }
>
> -static struct sysfs_ops md_sysfs_ops = {
> +static const struct sysfs_ops md_sysfs_ops = {
> .show = md_attr_show,
> .store = md_attr_store,
> };
> diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
> index 5862282..7cce8cb 100644
> --- a/drivers/net/ibmveth.c
> +++ b/drivers/net/ibmveth.c
> @@ -1577,7 +1577,7 @@ static struct attribute * veth_pool_attrs[] = {
> NULL,
> };
>
> -static struct sysfs_ops veth_pool_ops = {
> +static const struct sysfs_ops veth_pool_ops = {
> .show = veth_pool_show,
> .store = veth_pool_store,
> };
> diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
> index aa7286b..a61394f 100644
> --- a/drivers/net/iseries_veth.c
> +++ b/drivers/net/iseries_veth.c
> @@ -384,7 +384,7 @@ static struct attribute *veth_cnx_default_attrs[] = {
> NULL
> };
>
> -static struct sysfs_ops veth_cnx_sysfs_ops = {
> +static const struct sysfs_ops veth_cnx_sysfs_ops = {
> .show = veth_cnx_attribute_show
> };
>
> @@ -441,7 +441,7 @@ static struct attribute *veth_port_default_attrs[] = {
> NULL
> };
>
> -static struct sysfs_ops veth_port_sysfs_ops = {
> +static const struct sysfs_ops veth_port_sysfs_ops = {
> .show = veth_port_attribute_show
> };
>
> diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
> index 13a64bc..ad62835 100644
> --- a/drivers/parisc/pdc_stable.c
> +++ b/drivers/parisc/pdc_stable.c
> @@ -481,7 +481,7 @@ pdcspath_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static struct sysfs_ops pdcspath_attr_ops = {
> +static const struct sysfs_ops pdcspath_attr_ops = {
> .show = pdcspath_attr_show,
> .store = pdcspath_attr_store,
> };
> diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
> index 6151389..0a894ef 100644
> --- a/drivers/pci/hotplug/fakephp.c
> +++ b/drivers/pci/hotplug/fakephp.c
> @@ -73,7 +73,7 @@ static void legacy_release(struct kobject *kobj)
> }
>
> static struct kobj_type legacy_ktype = {
> - .sysfs_ops = &(struct sysfs_ops){
> + .sysfs_ops = &(const struct sysfs_ops){
> .store = legacy_store, .show = legacy_show
> },
> .release = &legacy_release,
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 8c02b6c..5584d8e 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -29,7 +29,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj,
> return attribute->store ? attribute->store(slot, buf, len) : -EIO;
> }
>
> -static struct sysfs_ops pci_slot_sysfs_ops = {
> +static const struct sysfs_ops pci_slot_sysfs_ops = {
> .show = pci_slot_attr_show,
> .store = pci_slot_attr_store,
> };
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index e941367..4de382a 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -129,7 +129,7 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
> return entry->show(mem, buf);
> }
>
> -static struct sysfs_ops map_sysfs_ops = {
> +static const struct sysfs_ops map_sysfs_ops = {
> .show = map_type_show,
> };
>
> @@ -217,7 +217,7 @@ static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr,
> return entry->show(port, buf);
> }
>
> -static struct sysfs_ops portio_sysfs_ops = {
> +static const struct sysfs_ops portio_sysfs_ops = {
> .show = portio_type_show,
> };
>
> diff --git a/drivers/uwb/wlp/sysfs.c b/drivers/uwb/wlp/sysfs.c
> index 0370399..6627c94 100644
> --- a/drivers/uwb/wlp/sysfs.c
> +++ b/drivers/uwb/wlp/sysfs.c
> @@ -615,8 +615,7 @@ ssize_t wlp_wss_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -static
> -struct sysfs_ops wss_sysfs_ops = {
> +static const struct sysfs_ops wss_sysfs_ops = {
> .show = wlp_wss_attr_show,
> .store = wlp_wss_attr_store,
> };
> diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
> index 88a60e0..6783cc2 100644
> --- a/drivers/xen/sys-hypervisor.c
> +++ b/drivers/xen/sys-hypervisor.c
> @@ -425,7 +425,7 @@ static ssize_t hyp_sysfs_store(struct kobject *kobj,
> return 0;
> }
>
> -static struct sysfs_ops hyp_sysfs_ops = {
> +static const struct sysfs_ops hyp_sysfs_ops = {
> .show = hyp_sysfs_show,
> .store = hyp_sysfs_store,
> };
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index a240b6f..4ce16ef 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -164,12 +164,12 @@ static void btrfs_root_release(struct kobject *kobj)
> complete(&root->kobj_unregister);
> }
>
> -static struct sysfs_ops btrfs_super_attr_ops = {
> +static const struct sysfs_ops btrfs_super_attr_ops = {
> .show = btrfs_super_attr_show,
> .store = btrfs_super_attr_store,
> };
>
> -static struct sysfs_ops btrfs_root_attr_ops = {
> +static const struct sysfs_ops btrfs_root_attr_ops = {
> .show = btrfs_root_attr_show,
> .store = btrfs_root_attr_store,
> };
> diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
> index d489fcc..5b0bd1e 100644
> --- a/fs/dlm/lockspace.c
> +++ b/fs/dlm/lockspace.c
> @@ -148,7 +148,7 @@ static void lockspace_kobj_release(struct kobject *k)
> kfree(ls);
> }
>
> -static struct sysfs_ops dlm_attr_ops = {
> +static const struct sysfs_ops dlm_attr_ops = {
> .show = dlm_attr_show,
> .store = dlm_attr_store,
> };
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index d4ca92a..b0594f3 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2251,7 +2251,7 @@ static void ext4_sb_release(struct kobject *kobj)
> }
>
>
> -static struct sysfs_ops ext4_attr_ops = {
> +static const struct sysfs_ops ext4_attr_ops = {
> .show = ext4_attr_show,
> .store = ext4_attr_store,
> };
> diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> index 4463297..cc946e8 100644
> --- a/fs/gfs2/sys.c
> +++ b/fs/gfs2/sys.c
> @@ -49,7 +49,7 @@ static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
> return a->store ? a->store(sdp, buf, len) : len;
> }
>
> -static struct sysfs_ops gfs2_attr_ops = {
> +static const struct sysfs_ops gfs2_attr_ops = {
> .show = gfs2_attr_show,
> .store = gfs2_attr_store,
> };
> diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
> index 1cd2934..880b5d2 100644
> --- a/fs/ocfs2/cluster/masklog.c
> +++ b/fs/ocfs2/cluster/masklog.c
> @@ -135,7 +135,7 @@ static ssize_t mlog_store(struct kobject *obj, struct attribute *attr,
> return mlog_mask_store(mlog_attr->mask, buf, count);
> }
>
> -static struct sysfs_ops mlog_attr_ops = {
> +static const struct sysfs_ops mlog_attr_ops = {
> .show = mlog_show,
> .store = mlog_store,
> };
> diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
> index f5ea468..b59b2e4 100644
> --- a/fs/sysfs/file.c
> +++ b/fs/sysfs/file.c
> @@ -53,7 +53,7 @@ struct sysfs_buffer {
> size_t count;
> loff_t pos;
> char * page;
> - struct sysfs_ops * ops;
> + const struct sysfs_ops * ops;
> struct mutex mutex;
> int needs_read_fill;
> int event;
> @@ -75,7 +75,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
> {
> struct sysfs_dirent *attr_sd = dentry->d_fsdata;
> struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
> - struct sysfs_ops * ops = buffer->ops;
> + const struct sysfs_ops * ops = buffer->ops;
> int ret = 0;
> ssize_t count;
>
> @@ -199,7 +199,7 @@ flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t
> {
> struct sysfs_dirent *attr_sd = dentry->d_fsdata;
> struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
> - struct sysfs_ops * ops = buffer->ops;
> + const struct sysfs_ops * ops = buffer->ops;
> int rc;
>
> /* need attr_sd for attr and ops, its parent for kobj */
> @@ -335,7 +335,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
> struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
> struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
> struct sysfs_buffer *buffer;
> - struct sysfs_ops *ops;
> + const struct sysfs_ops *ops;
> int error = -EACCES;
> char *p;
>
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index 58ae8e0..072cee4 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -106,7 +106,7 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
>
> struct kobj_type {
> void (*release)(struct kobject *kobj);
> - struct sysfs_ops *sysfs_ops;
> + const struct sysfs_ops *sysfs_ops;
> struct attribute **default_attrs;
> };
>
> @@ -132,7 +132,7 @@ struct kobj_attribute {
> const char *buf, size_t count);
> };
>
> -extern struct sysfs_ops kobj_sysfs_ops;
> +extern const struct sysfs_ops kobj_sysfs_ops;
>
> /**
> * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index 9d68fed..71f02cc 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -75,8 +75,8 @@ struct bin_attribute {
> };
>
> struct sysfs_ops {
> - ssize_t (*show)(struct kobject *, struct attribute *,char *);
> - ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
> + ssize_t (* const show)(struct kobject *, struct attribute *,char *);
> + ssize_t (* const store)(struct kobject *,struct attribute *,const char *, size_t);
> };
>
> struct sysfs_dirent;
> diff --git a/kernel/params.c b/kernel/params.c
> index d656c27..8b060d0 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -725,7 +725,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
> return ret;
> }
>
> -static struct sysfs_ops module_sysfs_ops = {
> +static const struct sysfs_ops module_sysfs_ops = {
> .show = module_attr_show,
> .store = module_attr_store,
> };
> diff --git a/lib/kobject.c b/lib/kobject.c
> index b512b74..6567393 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -700,7 +700,7 @@ static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
> return ret;
> }
>
> -struct sysfs_ops kobj_sysfs_ops = {
> +const struct sysfs_ops kobj_sysfs_ops = {
> .show = kobj_attr_show,
> .store = kobj_attr_store,
> };
> diff --git a/mm/slub.c b/mm/slub.c
> index 4996fc7..7c047ba 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4503,7 +4503,7 @@ static void kmem_cache_release(struct kobject *kobj)
> kfree(s);
> }
>
> -static struct sysfs_ops slab_sysfs_ops = {
> +static const struct sysfs_ops slab_sysfs_ops = {
> .show = slab_attr_show,
> .store = slab_attr_store,
> };
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 2114e45..c53bdd9 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -254,7 +254,7 @@ extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
>
> #ifdef CONFIG_SYSFS
> /* br_sysfs_if.c */
> -extern struct sysfs_ops brport_sysfs_ops;
> +extern const struct sysfs_ops brport_sysfs_ops;
> extern int br_sysfs_addif(struct net_bridge_port *p);
>
> /* br_sysfs_br.c */
> diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
> index 820643a..ce77fb3 100644
> --- a/net/bridge/br_sysfs_if.c
> +++ b/net/bridge/br_sysfs_if.c
> @@ -220,7 +220,7 @@ static ssize_t brport_store(struct kobject * kobj,
> return ret;
> }
>
> -struct sysfs_ops brport_sysfs_ops = {
> +const struct sysfs_ops brport_sysfs_ops = {
> .show = brport_show,
> .store = brport_store,
> };
> diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
> index 45b7d56..19e828c 100644
> --- a/samples/kobject/kset-example.c
> +++ b/samples/kobject/kset-example.c
> @@ -87,7 +87,7 @@ static ssize_t foo_attr_store(struct kobject *kobj,
> }
>
> /* Our custom sysfs_ops that we will associate with our ktype later on */
> -static struct sysfs_ops foo_sysfs_ops = {
> +static const struct sysfs_ops foo_sysfs_ops = {
> .show = foo_attr_show,
> .store = foo_attr_store,
> };
>
>

2009-12-04 23:00:59

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 22/31] Constify struct neigh_ops for 2.6.32 v1

Added [email protected] to CC.
> From: Emese Revfy <[email protected]>
>
> Constify struct neigh_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> include/net/neighbour.h | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/include/net/neighbour.h b/include/net/neighbour.h
> index 3817fda..2c61d38 100644
> --- a/include/net/neighbour.h
> +++ b/include/net/neighbour.h
> @@ -125,12 +125,12 @@ struct neighbour
> struct neigh_ops
> {
> int family;
> - void (*solicit)(struct neighbour *, struct sk_buff*);
> - void (*error_report)(struct neighbour *, struct sk_buff*);
> - int (*output)(struct sk_buff*);
> - int (*connected_output)(struct sk_buff*);
> - int (*hh_output)(struct sk_buff*);
> - int (*queue_xmit)(struct sk_buff*);
> + void (* const solicit)(struct neighbour *, struct sk_buff*);
> + void (* const error_report)(struct neighbour *, struct sk_buff*);
> + int (* const output)(struct sk_buff*);
> + int (* const connected_output)(struct sk_buff*);
> + int (* const hh_output)(struct sk_buff*);
> + int (* const queue_xmit)(struct sk_buff*);
> };
>
> struct pneigh_entry
>
>

2009-12-04 23:04:04

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 15/31] Constify struct iwl_ops for 2.6.32 v1

Added [email protected] and [email protected] to CC.
> From: Emese Revfy <[email protected]>
>
> Constify struct iwl_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> drivers/net/wireless/iwlwifi/iwl-1000.c | 2 +-
> drivers/net/wireless/iwlwifi/iwl-3945.c | 2 +-
> drivers/net/wireless/iwlwifi/iwl-4965.c | 2 +-
> drivers/net/wireless/iwlwifi/iwl-5000.c | 4 ++--
> drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +-
> drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +-
> 6 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
> index 950267a..80d5fd2 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-1000.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
> @@ -137,7 +137,7 @@ static struct iwl_lib_ops iwl1000_lib = {
> },
> };
>
> -static struct iwl_ops iwl1000_ops = {
> +static const struct iwl_ops iwl1000_ops = {
> .ucode = &iwl5000_ucode,
> .lib = &iwl1000_lib,
> .hcmd = &iwl5000_hcmd,
> diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
> index f059b49..fe90e0a 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-3945.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
> @@ -2876,7 +2876,7 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
> .build_addsta_hcmd = iwl3945_build_addsta_hcmd,
> };
>
> -static struct iwl_ops iwl3945_ops = {
> +static const struct iwl_ops iwl3945_ops = {
> .ucode = &iwl3945_ucode,
> .lib = &iwl3945_lib,
> .hcmd = &iwl3945_hcmd,
> diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
> index 6f703a0..b7c4e48 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-4965.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
> @@ -2335,7 +2335,7 @@ static struct iwl_lib_ops iwl4965_lib = {
> },
> };
>
> -static struct iwl_ops iwl4965_ops = {
> +static const struct iwl_ops iwl4965_ops = {
> .ucode = &iwl4965_ucode,
> .lib = &iwl4965_lib,
> .hcmd = &iwl4965_hcmd,
> diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
> index 6e6f516..0ec1f24 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-5000.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
> @@ -1627,14 +1627,14 @@ static struct iwl_lib_ops iwl5150_lib = {
> },
> };
>
> -struct iwl_ops iwl5000_ops = {
> +const struct iwl_ops iwl5000_ops = {
> .ucode = &iwl5000_ucode,
> .lib = &iwl5000_lib,
> .hcmd = &iwl5000_hcmd,
> .utils = &iwl5000_hcmd_utils,
> };
>
> -static struct iwl_ops iwl5150_ops = {
> +static const struct iwl_ops iwl5150_ops = {
> .ucode = &iwl5000_ucode,
> .lib = &iwl5150_lib,
> .hcmd = &iwl5000_hcmd,
> diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
> index 1473452..f07d5e1 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-6000.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
> @@ -146,7 +146,7 @@ static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
> .calc_rssi = iwl5000_calc_rssi,
> };
>
> -static struct iwl_ops iwl6000_ops = {
> +static const struct iwl_ops iwl6000_ops = {
> .ucode = &iwl5000_ucode,
> .lib = &iwl6000_lib,
> .hcmd = &iwl5000_hcmd,
> diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
> index 028d505..0c927e5 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-dev.h
> +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
> @@ -67,7 +67,7 @@ struct iwl_tx_queue;
>
> /* shared structures from iwl-5000.c */
> extern struct iwl_mod_params iwl50_mod_params;
> -extern struct iwl_ops iwl5000_ops;
> +extern const struct iwl_ops iwl5000_ops;
> extern struct iwl_ucode_ops iwl5000_ucode;
> extern struct iwl_lib_ops iwl5000_lib;
> extern struct iwl_hcmd_ops iwl5000_hcmd;
>
>

2009-12-04 23:06:37

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

Added [email protected] to CC.
> From: Emese Revfy <[email protected]>
>
> Constify struct file_operations with some exceptions.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> drivers/acpi/battery.c | 2 +-
> drivers/char/pty.c | 16 +++++++++---
> drivers/char/tty_io.c | 28 ++++-----------------
> drivers/media/dvb/dvb-core/dvbdev.c | 1 +
> drivers/net/wireless/b43/debugfs.c | 2 +-
> drivers/net/wireless/b43legacy/debugfs.c | 2 +-
> drivers/net/wireless/libertas/debugfs.c | 2 +-
> drivers/staging/b3dfg/b3dfg.c | 2 +-
> drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
> drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
> drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
> drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
> drivers/staging/dream/qdsp5/audio_in.c | 4 +-
> drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
> drivers/staging/dream/qdsp5/audio_out.c | 4 +-
> drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
> drivers/staging/dream/qdsp5/snd.c | 2 +-
> drivers/staging/dream/smd/smd_qmi.c | 2 +-
> drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 +-
> drivers/staging/panel/panel.c | 4 +-
> drivers/staging/poch/poch.c | 2 +-
> drivers/staging/sep/sep_driver.c | 2 +-
> drivers/staging/vme/devices/vme_user.c | 2 +-
> fs/fuse/cuse.c | 20 +++++++++------
> fs/fuse/dev.c | 8 +++---
> fs/fuse/fuse_i.h | 10 ++++++++
> include/linux/tty.h | 14 ++++++++++-
> include/net/tcp.h | 1 +
> include/net/udp.h | 1 +
> kernel/trace/trace_events.c | 2 +
> virt/kvm/kvm_main.c | 3 ++
> 31 files changed, 89 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 3f4602b..2e41d36 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
> }
>
> static struct battery_file {
> - struct file_operations ops;
> + const struct file_operations ops;
> mode_t mode;
> const char *name;
> } acpi_battery_file[] = {
> diff --git a/drivers/char/pty.c b/drivers/char/pty.c
> index 62f282e..d39c67b 100644
> --- a/drivers/char/pty.c
> +++ b/drivers/char/pty.c
> @@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
> return ret;
> }
>
> -static struct file_operations ptmx_fops;
> +static const struct file_operations ptmx_fops = {
> + .llseek = no_llseek,
> + .read = tty_read,
> + .write = tty_write,
> + .poll = tty_poll,
> + .unlocked_ioctl = tty_ioctl,
> + .compat_ioctl = tty_compat_ioctl,
> + .open = ptmx_open,
> + .release = tty_release,
> + .fasync = tty_fasync,
> +};
> +
>
> static void __init unix98_pty_init(void)
> {
> @@ -736,9 +747,6 @@ static void __init unix98_pty_init(void)
> register_sysctl_table(pty_root_table);
>
> /* Now create the /dev/ptmx special device */
> - tty_default_fops(&ptmx_fops);
> - ptmx_fops.open = ptmx_open;
> -
> cdev_init(&ptmx_cdev, &ptmx_fops);
> if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
> register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
> diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
> index 59499ee..9459c2d 100644
> --- a/drivers/char/tty_io.c
> +++ b/drivers/char/tty_io.c
> @@ -136,21 +136,10 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
> DEFINE_MUTEX(tty_mutex);
> EXPORT_SYMBOL(tty_mutex);
>
> -static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
> -static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
> ssize_t redirected_tty_write(struct file *, const char __user *,
> size_t, loff_t *);
> -static unsigned int tty_poll(struct file *, poll_table *);
> static int tty_open(struct inode *, struct file *);
> -static int tty_release(struct inode *, struct file *);
> long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> -#ifdef CONFIG_COMPAT
> -static long tty_compat_ioctl(struct file *file, unsigned int cmd,
> - unsigned long arg);
> -#else
> -#define tty_compat_ioctl NULL
> -#endif
> -static int tty_fasync(int fd, struct file *filp, int on);
> static void release_tty(struct tty_struct *tty, int idx);
> static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
> static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
> @@ -870,7 +859,7 @@ EXPORT_SYMBOL(start_tty);
> * read calls may be outstanding in parallel.
> */
>
> -static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
> +ssize_t tty_read(struct file *file, char __user *buf, size_t count,
> loff_t *ppos)
> {
> int i;
> @@ -1045,7 +1034,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
> * write method will not be invoked in parallel for each device.
> */
>
> -static ssize_t tty_write(struct file *file, const char __user *buf,
> +ssize_t tty_write(struct file *file, const char __user *buf,
> size_t count, loff_t *ppos)
> {
> struct tty_struct *tty;
> @@ -1865,7 +1854,7 @@ static int tty_open(struct inode *inode, struct file *filp)
> * Takes bkl. See tty_release_dev
> */
>
> -static int tty_release(struct inode *inode, struct file *filp)
> +int tty_release(struct inode *inode, struct file *filp)
> {
> lock_kernel();
> tty_release_dev(filp);
> @@ -1885,7 +1874,7 @@ static int tty_release(struct inode *inode, struct file *filp)
> * may be re-entered freely by other callers.
> */
>
> -static unsigned int tty_poll(struct file *filp, poll_table *wait)
> +unsigned int tty_poll(struct file *filp, poll_table *wait)
> {
> struct tty_struct *tty;
> struct tty_ldisc *ld;
> @@ -1902,7 +1891,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
> return ret;
> }
>
> -static int tty_fasync(int fd, struct file *filp, int on)
> +int tty_fasync(int fd, struct file *filp, int on)
> {
> struct tty_struct *tty;
> unsigned long flags;
> @@ -2579,7 +2568,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> }
>
> #ifdef CONFIG_COMPAT
> -static long tty_compat_ioctl(struct file *file, unsigned int cmd,
> +long tty_compat_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg)
> {
> struct inode *inode = file->f_dentry->d_inode;
> @@ -3046,11 +3035,6 @@ struct tty_struct *get_current_tty(void)
> }
> EXPORT_SYMBOL_GPL(get_current_tty);
>
> -void tty_default_fops(struct file_operations *fops)
> -{
> - *fops = tty_fops;
> -}
> -
> /*
> * Initialize the console device. This is called *early*, so
> * we can't necessarily depend on lots of kernel help here.
> diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
> index 94159b9..3eadb2e 100644
> --- a/drivers/media/dvb/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb/dvb-core/dvbdev.c
> @@ -191,6 +191,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
> const struct dvb_device *template, void *priv, int type)
> {
> struct dvb_device *dvbdev;
> + /* cannot be const */
> struct file_operations *dvbdevfops;
> struct device *clsdev;
> int minor;
> diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
> index 80b19a4..dab3a45 100644
> --- a/drivers/net/wireless/b43/debugfs.c
> +++ b/drivers/net/wireless/b43/debugfs.c
> @@ -43,7 +43,7 @@ static struct dentry *rootdir;
> struct b43_debugfs_fops {
> ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
> int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
> - struct file_operations fops;
> + const struct file_operations fops;
> /* Offset of struct b43_dfs_file in struct b43_dfsentry */
> size_t file_struct_offset;
> };
> diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
> index 1f85ac5..c99b4b4 100644
> --- a/drivers/net/wireless/b43legacy/debugfs.c
> +++ b/drivers/net/wireless/b43legacy/debugfs.c
> @@ -44,7 +44,7 @@ static struct dentry *rootdir;
> struct b43legacy_debugfs_fops {
> ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
> int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
> - struct file_operations fops;
> + const struct file_operations fops;
> /* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
> size_t file_struct_offset;
> /* Take wl->irq_lock before calling read/write? */
> diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
> index 893a55c..7f66a50 100644
> --- a/drivers/net/wireless/libertas/debugfs.c
> +++ b/drivers/net/wireless/libertas/debugfs.c
> @@ -708,7 +708,7 @@ out_unlock:
> struct lbs_debugfs_files {
> const char *name;
> int perm;
> - struct file_operations fops;
> + const struct file_operations fops;
> };
>
> static const struct lbs_debugfs_files debugfs_files[] = {
> diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
> index cda26bb..25f3ec6 100644
> --- a/drivers/staging/b3dfg/b3dfg.c
> +++ b/drivers/staging/b3dfg/b3dfg.c
> @@ -848,7 +848,7 @@ static int b3dfg_mmap(struct file *filp, struct vm_area_struct *vma)
> return r;
> }
>
> -static struct file_operations b3dfg_fops = {
> +static const struct file_operations b3dfg_fops = {
> .owner = THIS_MODULE,
> .open = b3dfg_open,
> .release = b3dfg_release,
> diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
> index e55a0db..577b776 100644
> --- a/drivers/staging/dream/qdsp5/adsp_driver.c
> +++ b/drivers/staging/dream/qdsp5/adsp_driver.c
> @@ -576,7 +576,7 @@ static struct adsp_device *inode_to_device(struct inode *inode)
> static dev_t adsp_devno;
> static struct class *adsp_class;
>
> -static struct file_operations adsp_fops = {
> +static const struct file_operations adsp_fops = {
> .owner = THIS_MODULE,
> .open = adsp_open,
> .unlocked_ioctl = adsp_ioctl,
> diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
> index ad2390f..4116ee8 100644
> --- a/drivers/staging/dream/qdsp5/audio_aac.c
> +++ b/drivers/staging/dream/qdsp5/audio_aac.c
> @@ -1022,7 +1022,7 @@ done:
> return rc;
> }
>
> -static struct file_operations audio_aac_fops = {
> +static const struct file_operations audio_aac_fops = {
> .owner = THIS_MODULE,
> .open = audio_open,
> .release = audio_release,
> diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
> index cd818a5..870b37b 100644
> --- a/drivers/staging/dream/qdsp5/audio_amrnb.c
> +++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
> @@ -833,7 +833,7 @@ done:
> return rc;
> }
>
> -static struct file_operations audio_amrnb_fops = {
> +static const struct file_operations audio_amrnb_fops = {
> .owner = THIS_MODULE,
> .open = audamrnb_open,
> .release = audamrnb_release,
> diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
> index 4b43e18..cedafda 100644
> --- a/drivers/staging/dream/qdsp5/audio_evrc.c
> +++ b/drivers/staging/dream/qdsp5/audio_evrc.c
> @@ -805,7 +805,7 @@ dma_fail:
> return rc;
> }
>
> -static struct file_operations audio_evrc_fops = {
> +static const struct file_operations audio_evrc_fops = {
> .owner = THIS_MODULE,
> .open = audevrc_open,
> .release = audevrc_release,
> diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
> index 3d950a2..9431118 100644
> --- a/drivers/staging/dream/qdsp5/audio_in.c
> +++ b/drivers/staging/dream/qdsp5/audio_in.c
> @@ -913,7 +913,7 @@ static int audpre_open(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static struct file_operations audio_fops = {
> +static const struct file_operations audio_fops = {
> .owner = THIS_MODULE,
> .open = audio_in_open,
> .release = audio_in_release,
> @@ -922,7 +922,7 @@ static struct file_operations audio_fops = {
> .unlocked_ioctl = audio_in_ioctl,
> };
>
> -static struct file_operations audpre_fops = {
> +static const struct file_operations audpre_fops = {
> .owner = THIS_MODULE,
> .open = audpre_open,
> .unlocked_ioctl = audpre_ioctl,
> diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
> index b95574f..286c2f4 100644
> --- a/drivers/staging/dream/qdsp5/audio_mp3.c
> +++ b/drivers/staging/dream/qdsp5/audio_mp3.c
> @@ -941,7 +941,7 @@ done:
> return rc;
> }
>
> -static struct file_operations audio_mp3_fops = {
> +static const struct file_operations audio_mp3_fops = {
> .owner = THIS_MODULE,
> .open = audio_open,
> .release = audio_release,
> diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
> index d1adcf6..f8f9833 100644
> --- a/drivers/staging/dream/qdsp5/audio_out.c
> +++ b/drivers/staging/dream/qdsp5/audio_out.c
> @@ -810,7 +810,7 @@ static int audpp_open(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static struct file_operations audio_fops = {
> +static const struct file_operations audio_fops = {
> .owner = THIS_MODULE,
> .open = audio_open,
> .release = audio_release,
> @@ -819,7 +819,7 @@ static struct file_operations audio_fops = {
> .unlocked_ioctl = audio_ioctl,
> };
>
> -static struct file_operations audpp_fops = {
> +static const struct file_operations audpp_fops = {
> .owner = THIS_MODULE,
> .open = audpp_open,
> .unlocked_ioctl = audpp_ioctl,
> diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
> index f0f50e3..f6b9dbc 100644
> --- a/drivers/staging/dream/qdsp5/audio_qcelp.c
> +++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
> @@ -816,7 +816,7 @@ err:
> return rc;
> }
>
> -static struct file_operations audio_qcelp_fops = {
> +static const struct file_operations audio_qcelp_fops = {
> .owner = THIS_MODULE,
> .open = audqcelp_open,
> .release = audqcelp_release,
> diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
> index 037d7ff..5469ec3 100644
> --- a/drivers/staging/dream/qdsp5/snd.c
> +++ b/drivers/staging/dream/qdsp5/snd.c
> @@ -242,7 +242,7 @@ err:
> return rc;
> }
>
> -static struct file_operations snd_fops = {
> +static const struct file_operations snd_fops = {
> .owner = THIS_MODULE,
> .open = snd_open,
> .release = snd_release,
> diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c
> index d4e7d88..0ea632a 100644
> --- a/drivers/staging/dream/smd/smd_qmi.c
> +++ b/drivers/staging/dream/smd/smd_qmi.c
> @@ -793,7 +793,7 @@ static int qmi_release(struct inode *ip, struct file *fp)
> return 0;
> }
>
> -static struct file_operations qmi_fops = {
> +static const struct file_operations qmi_fops = {
> .owner = THIS_MODULE,
> .read = qmi_read,
> .write = qmi_write,
> diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
> index cd3910b..ff053d3 100644
> --- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
> +++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
> @@ -214,7 +214,7 @@ static long rpcrouter_ioctl(struct file *filp, unsigned int cmd,
> return rc;
> }
>
> -static struct file_operations rpcrouter_server_fops = {
> +static const struct file_operations rpcrouter_server_fops = {
> .owner = THIS_MODULE,
> .open = rpcrouter_open,
> .release = rpcrouter_release,
> @@ -224,7 +224,7 @@ static struct file_operations rpcrouter_server_fops = {
> .unlocked_ioctl = rpcrouter_ioctl,
> };
>
> -static struct file_operations rpcrouter_router_fops = {
> +static const struct file_operations rpcrouter_router_fops = {
> .owner = THIS_MODULE,
> .open = rpcrouter_open,
> .release = rpcrouter_release,
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index 4ce399b..225f9bc 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -1305,7 +1305,7 @@ static int lcd_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static struct file_operations lcd_fops = {
> +static const struct file_operations lcd_fops = {
> .write = lcd_write,
> .open = lcd_open,
> .release = lcd_release,
> @@ -1565,7 +1565,7 @@ static int keypad_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static struct file_operations keypad_fops = {
> +static const struct file_operations keypad_fops = {
> .read = keypad_read, /* read */
> .open = keypad_open, /* open */
> .release = keypad_release, /* close */
> diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
> index 2eb8e3d..57616a7 100644
> --- a/drivers/staging/poch/poch.c
> +++ b/drivers/staging/poch/poch.c
> @@ -1057,7 +1057,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
> return 0;
> }
>
> -static struct file_operations poch_fops = {
> +static const struct file_operations poch_fops = {
> .owner = THIS_MODULE,
> .open = poch_open,
> .release = poch_release,
> diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
> index f890a16..509ece8 100644
> --- a/drivers/staging/sep/sep_driver.c
> +++ b/drivers/staging/sep/sep_driver.c
> @@ -2603,7 +2603,7 @@ static struct pci_driver sep_pci_driver = {
> static dev_t sep_devno;
>
> /* the files operations structure of the driver */
> -static struct file_operations sep_file_operations = {
> +static const struct file_operations sep_file_operations = {
> .owner = THIS_MODULE,
> .ioctl = sep_ioctl,
> .poll = sep_poll,
> diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
> index 7891288..8e31300 100644
> --- a/drivers/staging/vme/devices/vme_user.c
> +++ b/drivers/staging/vme/devices/vme_user.c
> @@ -136,7 +136,7 @@ static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
> static int __init vme_user_probe(struct device *, int, int);
> static int __exit vme_user_remove(struct device *, int, int);
>
> -static struct file_operations vme_user_fops = {
> +static const struct file_operations vme_user_fops = {
> .open = vme_user_open,
> .release = vme_user_release,
> .read = vme_user_read,
> diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
> index de792dc..40bbb90 100644
> --- a/fs/fuse/cuse.c
> +++ b/fs/fuse/cuse.c
> @@ -528,8 +528,18 @@ static int cuse_channel_release(struct inode *inode, struct file *file)
> return rc;
> }
>
> -static struct file_operations cuse_channel_fops; /* initialized during init */
> -
> +static const struct file_operations cuse_channel_fops = { /* initialized during init */
> + .owner = THIS_MODULE,
> + .llseek = no_llseek,
> + .read = do_sync_read,
> + .aio_read = fuse_dev_read,
> + .write = do_sync_write,
> + .aio_write = fuse_dev_write,
> + .poll = fuse_dev_poll,
> + .open = cuse_channel_open,
> + .release = cuse_channel_release,
> + .fasync = fuse_dev_fasync,
> +};
>
> /**************************************************************************
> * Misc stuff and module initializatiion
> @@ -575,12 +585,6 @@ static int __init cuse_init(void)
> for (i = 0; i < CUSE_CONNTBL_LEN; i++)
> INIT_LIST_HEAD(&cuse_conntbl[i]);
>
> - /* inherit and extend fuse_dev_operations */
> - cuse_channel_fops = fuse_dev_operations;
> - cuse_channel_fops.owner = THIS_MODULE;
> - cuse_channel_fops.open = cuse_channel_open;
> - cuse_channel_fops.release = cuse_channel_release;
> -
> cuse_class = class_create(THIS_MODULE, "cuse");
> if (IS_ERR(cuse_class))
> return PTR_ERR(cuse_class);
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 51d9e33..03c8f95 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -745,7 +745,7 @@ __releases(&fc->lock)
> * request_end(). Otherwise add it to the processing list, and set
> * the 'sent' flag.
> */
> -static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
> +ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
> unsigned long nr_segs, loff_t pos)
> {
> int err;
> @@ -987,7 +987,7 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out,
> * it from the list and copy the rest of the buffer to the request.
> * The request is finished by calling request_end()
> */
> -static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
> +ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
> unsigned long nr_segs, loff_t pos)
> {
> int err;
> @@ -1084,7 +1084,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
> return err;
> }
>
> -static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
> +unsigned fuse_dev_poll(struct file *file, poll_table *wait)
> {
> unsigned mask = POLLOUT | POLLWRNORM;
> struct fuse_conn *fc = fuse_get_conn(file);
> @@ -1210,7 +1210,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
> }
> EXPORT_SYMBOL_GPL(fuse_dev_release);
>
> -static int fuse_dev_fasync(int fd, struct file *file, int on)
> +int fuse_dev_fasync(int fd, struct file *file, int on)
> {
> struct fuse_conn *fc = fuse_get_conn(file);
> if (!fc)
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 01cc462..b11fe78 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -521,6 +521,16 @@ extern const struct file_operations fuse_dev_operations;
>
> extern const struct dentry_operations fuse_dentry_operations;
>
> +extern ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
> + unsigned long nr_segs, loff_t pos);
> +
> +extern ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
> + unsigned long nr_segs, loff_t pos);
> +
> +extern unsigned fuse_dev_poll(struct file *file, poll_table *wait);
> +
> +extern int fuse_dev_fasync(int fd, struct file *file, int on);
> +
> /**
> * Inode to nodeid comparison.
> */
> diff --git a/include/linux/tty.h b/include/linux/tty.h
> index f0f43d0..caee8aa 100644
> --- a/include/linux/tty.h
> +++ b/include/linux/tty.h
> @@ -13,6 +13,7 @@
> #include <linux/tty_driver.h>
> #include <linux/tty_ldisc.h>
> #include <linux/mutex.h>
> +#include <linux/poll.h>
>
> #include <asm/system.h>
>
> @@ -432,7 +433,6 @@ extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
> extern dev_t tty_devnum(struct tty_struct *tty);
> extern void proc_clear_tty(struct task_struct *p);
> extern struct tty_struct *get_current_tty(void);
> -extern void tty_default_fops(struct file_operations *fops);
> extern struct tty_struct *alloc_tty_struct(void);
> extern void free_tty_struct(struct tty_struct *tty);
> extern void initialize_tty_struct(struct tty_struct *tty,
> @@ -482,6 +482,18 @@ extern void tty_ldisc_begin(void);
> /* This last one is just for the tty layer internals and shouldn't be used elsewhere */
> extern void tty_ldisc_enable(struct tty_struct *tty);
>
> +/* tty_io.c */
> +extern ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
> +extern ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
> +extern unsigned int tty_poll(struct file *, poll_table *);
> +#ifdef CONFIG_COMPAT
> +extern long tty_compat_ioctl(struct file *file, unsigned int cmd,
> + unsigned long arg);
> +#else
> +#define tty_compat_ioctl NULL
> +#endif
> +extern int tty_release(struct inode *, struct file *);
> +extern int tty_fasync(int fd, struct file *filp, int on);
>
> /* n_tty.c */
> extern struct tty_ldisc_ops tty_ldisc_N_TTY;
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 03a49c7..e689dcf 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1414,6 +1414,7 @@ enum tcp_seq_states {
> struct tcp_seq_afinfo {
> char *name;
> sa_family_t family;
> + /* cannot be const */
> struct file_operations seq_fops;
> struct seq_operations seq_ops;
> };
> diff --git a/include/net/udp.h b/include/net/udp.h
> index f98abd2..2e6c0a3 100644
> --- a/include/net/udp.h
> +++ b/include/net/udp.h
> @@ -187,6 +187,7 @@ struct udp_seq_afinfo {
> char *name;
> sa_family_t family;
> struct udp_table *udp_table;
> + /* cannot be const */
> struct file_operations seq_fops;
> struct seq_operations seq_ops;
> };
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index d128f65..cfcc06e 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -951,6 +951,8 @@ static LIST_HEAD(ftrace_module_file_list);
> * Modules must own their file_operations to keep up with
> * reference counting.
> */
> +
> +/* cannot be const */
> struct ftrace_module_file_ops {
> struct list_head list;
> struct module *mod;
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 7495ce3..d0a3cc0 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1745,6 +1745,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
> return 0;
> }
>
> +/* cannot be const */
> static struct file_operations kvm_vcpu_fops = {
> .release = kvm_vcpu_release,
> .unlocked_ioctl = kvm_vcpu_ioctl,
> @@ -2341,6 +2342,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
> return 0;
> }
>
> +/* cannot be const */
> static struct file_operations kvm_vm_fops = {
> .release = kvm_vm_release,
> .unlocked_ioctl = kvm_vm_ioctl,
> @@ -2428,6 +2430,7 @@ out:
> return r;
> }
>
> +/* cannot be const */
> static struct file_operations kvm_chardev_ops = {
> .unlocked_ioctl = kvm_dev_ioctl,
> .compat_ioctl = kvm_dev_ioctl,
>
>

2009-12-04 23:19:36

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 22/31] Constify struct neigh_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>
Date: Sat, 05 Dec 2009 00:02:48 +0100

> Added [email protected] to CC.

It is better to make the proper patch posting again to
netdev, otherwise your patch will not get tracked and
watched over at patchwork.ozlabs.org

2009-12-05 00:00:14

by Stephen Hemminger

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Fri, 04 Dec 2009 23:49:06 +0100
Emese Revfy <[email protected]> wrote:

> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>

Acked-by: Stephen Hemminger <[email protected]>

--

2009-12-05 00:01:01

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 22/31] Constify struct neigh_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct neigh_ops.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
include/net/neighbour.h | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 3817fda..2c61d38 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -125,12 +125,12 @@ struct neighbour
struct neigh_ops
{
int family;
- void (*solicit)(struct neighbour *, struct sk_buff*);
- void (*error_report)(struct neighbour *, struct sk_buff*);
- int (*output)(struct sk_buff*);
- int (*connected_output)(struct sk_buff*);
- int (*hh_output)(struct sk_buff*);
- int (*queue_xmit)(struct sk_buff*);
+ void (* const solicit)(struct neighbour *, struct sk_buff*);
+ void (* const error_report)(struct neighbour *, struct sk_buff*);
+ int (* const output)(struct sk_buff*);
+ int (* const connected_output)(struct sk_buff*);
+ int (* const hh_output)(struct sk_buff*);
+ int (* const queue_xmit)(struct sk_buff*);
};

struct pneigh_entry

2009-12-05 00:03:00

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 15/31] Constify struct iwl_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct iwl_ops.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-1000.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-3945.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-4965.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-5000.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 950267a..80d5fd2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -137,7 +137,7 @@ static struct iwl_lib_ops iwl1000_lib = {
},
};

-static struct iwl_ops iwl1000_ops = {
+static const struct iwl_ops iwl1000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl1000_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index f059b49..fe90e0a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2876,7 +2876,7 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
.build_addsta_hcmd = iwl3945_build_addsta_hcmd,
};

-static struct iwl_ops iwl3945_ops = {
+static const struct iwl_ops iwl3945_ops = {
.ucode = &iwl3945_ucode,
.lib = &iwl3945_lib,
.hcmd = &iwl3945_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 6f703a0..b7c4e48 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2335,7 +2335,7 @@ static struct iwl_lib_ops iwl4965_lib = {
},
};

-static struct iwl_ops iwl4965_ops = {
+static const struct iwl_ops iwl4965_ops = {
.ucode = &iwl4965_ucode,
.lib = &iwl4965_lib,
.hcmd = &iwl4965_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 6e6f516..0ec1f24 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1627,14 +1627,14 @@ static struct iwl_lib_ops iwl5150_lib = {
},
};

-struct iwl_ops iwl5000_ops = {
+const struct iwl_ops iwl5000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl5000_lib,
.hcmd = &iwl5000_hcmd,
.utils = &iwl5000_hcmd_utils,
};

-static struct iwl_ops iwl5150_ops = {
+static const struct iwl_ops iwl5150_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl5150_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 1473452..f07d5e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -146,7 +146,7 @@ static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
.calc_rssi = iwl5000_calc_rssi,
};

-static struct iwl_ops iwl6000_ops = {
+static const struct iwl_ops iwl6000_ops = {
.ucode = &iwl5000_ucode,
.lib = &iwl6000_lib,
.hcmd = &iwl5000_hcmd,
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 028d505..0c927e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -67,7 +67,7 @@ struct iwl_tx_queue;

/* shared structures from iwl-5000.c */
extern struct iwl_mod_params iwl50_mod_params;
-extern struct iwl_ops iwl5000_ops;
+extern const struct iwl_ops iwl5000_ops;
extern struct iwl_ucode_ops iwl5000_ucode;
extern struct iwl_lib_ops iwl5000_lib;
extern struct iwl_hcmd_ops iwl5000_hcmd;

2009-12-05 00:02:06

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct file_operations with some exceptions.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/battery.c | 2 +-
drivers/char/pty.c | 16 +++++++++---
drivers/char/tty_io.c | 28 ++++-----------------
drivers/media/dvb/dvb-core/dvbdev.c | 1 +
drivers/net/wireless/b43/debugfs.c | 2 +-
drivers/net/wireless/b43legacy/debugfs.c | 2 +-
drivers/net/wireless/libertas/debugfs.c | 2 +-
drivers/staging/b3dfg/b3dfg.c | 2 +-
drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
drivers/staging/dream/qdsp5/audio_in.c | 4 +-
drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
drivers/staging/dream/qdsp5/audio_out.c | 4 +-
drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
drivers/staging/dream/qdsp5/snd.c | 2 +-
drivers/staging/dream/smd/smd_qmi.c | 2 +-
drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 +-
drivers/staging/panel/panel.c | 4 +-
drivers/staging/poch/poch.c | 2 +-
drivers/staging/sep/sep_driver.c | 2 +-
drivers/staging/vme/devices/vme_user.c | 2 +-
fs/fuse/cuse.c | 20 +++++++++------
fs/fuse/dev.c | 8 +++---
fs/fuse/fuse_i.h | 10 ++++++++
include/linux/tty.h | 14 ++++++++++-
include/net/tcp.h | 1 +
include/net/udp.h | 1 +
kernel/trace/trace_events.c | 2 +
virt/kvm/kvm_main.c | 3 ++
31 files changed, 89 insertions(+), 63 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3f4602b..2e41d36 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
}

static struct battery_file {
- struct file_operations ops;
+ const struct file_operations ops;
mode_t mode;
const char *name;
} acpi_battery_file[] = {
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 62f282e..d39c67b 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
return ret;
}

-static struct file_operations ptmx_fops;
+static const struct file_operations ptmx_fops = {
+ .llseek = no_llseek,
+ .read = tty_read,
+ .write = tty_write,
+ .poll = tty_poll,
+ .unlocked_ioctl = tty_ioctl,
+ .compat_ioctl = tty_compat_ioctl,
+ .open = ptmx_open,
+ .release = tty_release,
+ .fasync = tty_fasync,
+};
+

static void __init unix98_pty_init(void)
{
@@ -736,9 +747,6 @@ static void __init unix98_pty_init(void)
register_sysctl_table(pty_root_table);

/* Now create the /dev/ptmx special device */
- tty_default_fops(&ptmx_fops);
- ptmx_fops.open = ptmx_open;
-
cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 59499ee..9459c2d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -136,21 +136,10 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
DEFINE_MUTEX(tty_mutex);
EXPORT_SYMBOL(tty_mutex);

-static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
ssize_t redirected_tty_write(struct file *, const char __user *,
size_t, loff_t *);
-static unsigned int tty_poll(struct file *, poll_table *);
static int tty_open(struct inode *, struct file *);
-static int tty_release(struct inode *, struct file *);
long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-static long tty_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg);
-#else
-#define tty_compat_ioctl NULL
-#endif
-static int tty_fasync(int fd, struct file *filp, int on);
static void release_tty(struct tty_struct *tty, int idx);
static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
@@ -870,7 +859,7 @@ EXPORT_SYMBOL(start_tty);
* read calls may be outstanding in parallel.
*/

-static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
+ssize_t tty_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
int i;
@@ -1045,7 +1034,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
* write method will not be invoked in parallel for each device.
*/

-static ssize_t tty_write(struct file *file, const char __user *buf,
+ssize_t tty_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct tty_struct *tty;
@@ -1865,7 +1854,7 @@ static int tty_open(struct inode *inode, struct file *filp)
* Takes bkl. See tty_release_dev
*/

-static int tty_release(struct inode *inode, struct file *filp)
+int tty_release(struct inode *inode, struct file *filp)
{
lock_kernel();
tty_release_dev(filp);
@@ -1885,7 +1874,7 @@ static int tty_release(struct inode *inode, struct file *filp)
* may be re-entered freely by other callers.
*/

-static unsigned int tty_poll(struct file *filp, poll_table *wait)
+unsigned int tty_poll(struct file *filp, poll_table *wait)
{
struct tty_struct *tty;
struct tty_ldisc *ld;
@@ -1902,7 +1891,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
return ret;
}

-static int tty_fasync(int fd, struct file *filp, int on)
+int tty_fasync(int fd, struct file *filp, int on)
{
struct tty_struct *tty;
unsigned long flags;
@@ -2579,7 +2568,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}

#ifdef CONFIG_COMPAT
-static long tty_compat_ioctl(struct file *file, unsigned int cmd,
+long tty_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct inode *inode = file->f_dentry->d_inode;
@@ -3046,11 +3035,6 @@ struct tty_struct *get_current_tty(void)
}
EXPORT_SYMBOL_GPL(get_current_tty);

-void tty_default_fops(struct file_operations *fops)
-{
- *fops = tty_fops;
-}
-
/*
* Initialize the console device. This is called *early*, so
* we can't necessarily depend on lots of kernel help here.
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..3eadb2e 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -191,6 +191,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type)
{
struct dvb_device *dvbdev;
+ /* cannot be const */
struct file_operations *dvbdevfops;
struct device *clsdev;
int minor;
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 80b19a4..dab3a45 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -43,7 +43,7 @@ static struct dentry *rootdir;
struct b43_debugfs_fops {
ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43_dfs_file in struct b43_dfsentry */
size_t file_struct_offset;
};
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 1f85ac5..c99b4b4 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -44,7 +44,7 @@ static struct dentry *rootdir;
struct b43legacy_debugfs_fops {
ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
size_t file_struct_offset;
/* Take wl->irq_lock before calling read/write? */
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 893a55c..7f66a50 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -708,7 +708,7 @@ out_unlock:
struct lbs_debugfs_files {
const char *name;
int perm;
- struct file_operations fops;
+ const struct file_operations fops;
};

static const struct lbs_debugfs_files debugfs_files[] = {
diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index cda26bb..25f3ec6 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -848,7 +848,7 @@ static int b3dfg_mmap(struct file *filp, struct vm_area_struct *vma)
return r;
}

-static struct file_operations b3dfg_fops = {
+static const struct file_operations b3dfg_fops = {
.owner = THIS_MODULE,
.open = b3dfg_open,
.release = b3dfg_release,
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index e55a0db..577b776 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -576,7 +576,7 @@ static struct adsp_device *inode_to_device(struct inode *inode)
static dev_t adsp_devno;
static struct class *adsp_class;

-static struct file_operations adsp_fops = {
+static const struct file_operations adsp_fops = {
.owner = THIS_MODULE,
.open = adsp_open,
.unlocked_ioctl = adsp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index ad2390f..4116ee8 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -1022,7 +1022,7 @@ done:
return rc;
}

-static struct file_operations audio_aac_fops = {
+static const struct file_operations audio_aac_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index cd818a5..870b37b 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -833,7 +833,7 @@ done:
return rc;
}

-static struct file_operations audio_amrnb_fops = {
+static const struct file_operations audio_amrnb_fops = {
.owner = THIS_MODULE,
.open = audamrnb_open,
.release = audamrnb_release,
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index 4b43e18..cedafda 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -805,7 +805,7 @@ dma_fail:
return rc;
}

-static struct file_operations audio_evrc_fops = {
+static const struct file_operations audio_evrc_fops = {
.owner = THIS_MODULE,
.open = audevrc_open,
.release = audevrc_release,
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 3d950a2..9431118 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -913,7 +913,7 @@ static int audpre_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_in_open,
.release = audio_in_release,
@@ -922,7 +922,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_in_ioctl,
};

-static struct file_operations audpre_fops = {
+static const struct file_operations audpre_fops = {
.owner = THIS_MODULE,
.open = audpre_open,
.unlocked_ioctl = audpre_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index b95574f..286c2f4 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -941,7 +941,7 @@ done:
return rc;
}

-static struct file_operations audio_mp3_fops = {
+static const struct file_operations audio_mp3_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index d1adcf6..f8f9833 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -810,7 +810,7 @@ static int audpp_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
@@ -819,7 +819,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_ioctl,
};

-static struct file_operations audpp_fops = {
+static const struct file_operations audpp_fops = {
.owner = THIS_MODULE,
.open = audpp_open,
.unlocked_ioctl = audpp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index f0f50e3..f6b9dbc 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -816,7 +816,7 @@ err:
return rc;
}

-static struct file_operations audio_qcelp_fops = {
+static const struct file_operations audio_qcelp_fops = {
.owner = THIS_MODULE,
.open = audqcelp_open,
.release = audqcelp_release,
diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
index 037d7ff..5469ec3 100644
--- a/drivers/staging/dream/qdsp5/snd.c
+++ b/drivers/staging/dream/qdsp5/snd.c
@@ -242,7 +242,7 @@ err:
return rc;
}

-static struct file_operations snd_fops = {
+static const struct file_operations snd_fops = {
.owner = THIS_MODULE,
.open = snd_open,
.release = snd_release,
diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c
index d4e7d88..0ea632a 100644
--- a/drivers/staging/dream/smd/smd_qmi.c
+++ b/drivers/staging/dream/smd/smd_qmi.c
@@ -793,7 +793,7 @@ static int qmi_release(struct inode *ip, struct file *fp)
return 0;
}

-static struct file_operations qmi_fops = {
+static const struct file_operations qmi_fops = {
.owner = THIS_MODULE,
.read = qmi_read,
.write = qmi_write,
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
index cd3910b..ff053d3 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
@@ -214,7 +214,7 @@ static long rpcrouter_ioctl(struct file *filp, unsigned int cmd,
return rc;
}

-static struct file_operations rpcrouter_server_fops = {
+static const struct file_operations rpcrouter_server_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
@@ -224,7 +224,7 @@ static struct file_operations rpcrouter_server_fops = {
.unlocked_ioctl = rpcrouter_ioctl,
};

-static struct file_operations rpcrouter_router_fops = {
+static const struct file_operations rpcrouter_router_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 4ce399b..225f9bc 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -1305,7 +1305,7 @@ static int lcd_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations lcd_fops = {
+static const struct file_operations lcd_fops = {
.write = lcd_write,
.open = lcd_open,
.release = lcd_release,
@@ -1565,7 +1565,7 @@ static int keypad_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations keypad_fops = {
+static const struct file_operations keypad_fops = {
.read = keypad_read, /* read */
.open = keypad_open, /* open */
.release = keypad_release, /* close */
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index 2eb8e3d..57616a7 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1057,7 +1057,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
return 0;
}

-static struct file_operations poch_fops = {
+static const struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index f890a16..509ece8 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -2603,7 +2603,7 @@ static struct pci_driver sep_pci_driver = {
static dev_t sep_devno;

/* the files operations structure of the driver */
-static struct file_operations sep_file_operations = {
+static const struct file_operations sep_file_operations = {
.owner = THIS_MODULE,
.ioctl = sep_ioctl,
.poll = sep_poll,
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 7891288..8e31300 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -136,7 +136,7 @@ static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
static int __init vme_user_probe(struct device *, int, int);
static int __exit vme_user_remove(struct device *, int, int);

-static struct file_operations vme_user_fops = {
+static const struct file_operations vme_user_fops = {
.open = vme_user_open,
.release = vme_user_release,
.read = vme_user_read,
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index de792dc..40bbb90 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -528,8 +528,18 @@ static int cuse_channel_release(struct inode *inode, struct file *file)
return rc;
}

-static struct file_operations cuse_channel_fops; /* initialized during init */
-
+static const struct file_operations cuse_channel_fops = { /* initialized during init */
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = do_sync_read,
+ .aio_read = fuse_dev_read,
+ .write = do_sync_write,
+ .aio_write = fuse_dev_write,
+ .poll = fuse_dev_poll,
+ .open = cuse_channel_open,
+ .release = cuse_channel_release,
+ .fasync = fuse_dev_fasync,
+};

/**************************************************************************
* Misc stuff and module initializatiion
@@ -575,12 +585,6 @@ static int __init cuse_init(void)
for (i = 0; i < CUSE_CONNTBL_LEN; i++)
INIT_LIST_HEAD(&cuse_conntbl[i]);

- /* inherit and extend fuse_dev_operations */
- cuse_channel_fops = fuse_dev_operations;
- cuse_channel_fops.owner = THIS_MODULE;
- cuse_channel_fops.open = cuse_channel_open;
- cuse_channel_fops.release = cuse_channel_release;
-
cuse_class = class_create(THIS_MODULE, "cuse");
if (IS_ERR(cuse_class))
return PTR_ERR(cuse_class);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 51d9e33..03c8f95 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -745,7 +745,7 @@ __releases(&fc->lock)
* request_end(). Otherwise add it to the processing list, and set
* the 'sent' flag.
*/
-static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -987,7 +987,7 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out,
* it from the list and copy the rest of the buffer to the request.
* The request is finished by calling request_end()
*/
-static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -1084,7 +1084,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
return err;
}

-static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
+unsigned fuse_dev_poll(struct file *file, poll_table *wait)
{
unsigned mask = POLLOUT | POLLWRNORM;
struct fuse_conn *fc = fuse_get_conn(file);
@@ -1210,7 +1210,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
}
EXPORT_SYMBOL_GPL(fuse_dev_release);

-static int fuse_dev_fasync(int fd, struct file *file, int on)
+int fuse_dev_fasync(int fd, struct file *file, int on)
{
struct fuse_conn *fc = fuse_get_conn(file);
if (!fc)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 01cc462..b11fe78 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -521,6 +521,16 @@ extern const struct file_operations fuse_dev_operations;

extern const struct dentry_operations fuse_dentry_operations;

+extern ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern unsigned fuse_dev_poll(struct file *file, poll_table *wait);
+
+extern int fuse_dev_fasync(int fd, struct file *file, int on);
+
/**
* Inode to nodeid comparison.
*/
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f0f43d0..caee8aa 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,6 +13,7 @@
#include <linux/tty_driver.h>
#include <linux/tty_ldisc.h>
#include <linux/mutex.h>
+#include <linux/poll.h>

#include <asm/system.h>

@@ -432,7 +433,6 @@ extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
extern dev_t tty_devnum(struct tty_struct *tty);
extern void proc_clear_tty(struct task_struct *p);
extern struct tty_struct *get_current_tty(void);
-extern void tty_default_fops(struct file_operations *fops);
extern struct tty_struct *alloc_tty_struct(void);
extern void free_tty_struct(struct tty_struct *tty);
extern void initialize_tty_struct(struct tty_struct *tty,
@@ -482,6 +482,18 @@ extern void tty_ldisc_begin(void);
/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
extern void tty_ldisc_enable(struct tty_struct *tty);

+/* tty_io.c */
+extern ssize_t tty_read(struct file *, char __user *, size_t, loff_t *);
+extern ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
+extern unsigned int tty_poll(struct file *, poll_table *);
+#ifdef CONFIG_COMPAT
+extern long tty_compat_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg);
+#else
+#define tty_compat_ioctl NULL
+#endif
+extern int tty_release(struct inode *, struct file *);
+extern int tty_fasync(int fd, struct file *filp, int on);

/* n_tty.c */
extern struct tty_ldisc_ops tty_ldisc_N_TTY;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 03a49c7..e689dcf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1414,6 +1414,7 @@ enum tcp_seq_states {
struct tcp_seq_afinfo {
char *name;
sa_family_t family;
+ /* cannot be const */
struct file_operations seq_fops;
struct seq_operations seq_ops;
};
diff --git a/include/net/udp.h b/include/net/udp.h
index f98abd2..2e6c0a3 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -187,6 +187,7 @@ struct udp_seq_afinfo {
char *name;
sa_family_t family;
struct udp_table *udp_table;
+ /* cannot be const */
struct file_operations seq_fops;
struct seq_operations seq_ops;
};
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index d128f65..cfcc06e 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -951,6 +951,8 @@ static LIST_HEAD(ftrace_module_file_list);
* Modules must own their file_operations to keep up with
* reference counting.
*/
+
+/* cannot be const */
struct ftrace_module_file_ops {
struct list_head list;
struct module *mod;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7495ce3..d0a3cc0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1745,6 +1745,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
return 0;
}

+/* cannot be const */
static struct file_operations kvm_vcpu_fops = {
.release = kvm_vcpu_release,
.unlocked_ioctl = kvm_vcpu_ioctl,
@@ -2341,6 +2342,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}

+/* cannot be const */
static struct file_operations kvm_vm_fops = {
.release = kvm_vm_release,
.unlocked_ioctl = kvm_vm_ioctl,
@@ -2428,6 +2430,7 @@ out:
return r;
}

+/* cannot be const */
static struct file_operations kvm_chardev_ops = {
.unlocked_ioctl = kvm_dev_ioctl,
.compat_ioctl = kvm_dev_ioctl,

2009-12-05 00:01:12

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 08/31] Constify struct e1000_phy_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_phy_operations.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 6 +++---
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..9457254 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1674,7 +1674,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations e82_phy_ops_igp = {
+static const struct e1000_phy_operations e82_phy_ops_igp = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = NULL,
@@ -1691,7 +1691,7 @@ static struct e1000_phy_operations e82_phy_ops_igp = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_m88 = {
+static const struct e1000_phy_operations e82_phy_ops_m88 = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
@@ -1708,7 +1708,7 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_bm = {
+static const struct e1000_phy_operations e82_phy_ops_bm = {
.acquire_phy = e1000_get_hw_semaphore_82571,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..7744c27 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -376,7 +376,7 @@ struct e1000_info {
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..631c037 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1383,7 +1383,7 @@ static struct e1000_mac_operations es2_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations es2_phy_ops = {
+static const struct e1000_phy_operations es2_phy_ops = {
.acquire_phy = e1000_acquire_phy_80003es2lan,
.check_reset_block = e1000e_check_reset_block_generic,
.commit_phy = e1000e_phy_sw_reset,
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..ca9d830 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3469,7 +3469,7 @@ static struct e1000_mac_operations ich8_mac_ops = {
/* id_led_init dependent on mac type */
};

-static struct e1000_phy_operations ich8_phy_ops = {
+static const struct e1000_phy_operations ich8_phy_ops = {
.acquire_phy = e1000_acquire_swflag_ich8lan,
.check_reset_block = e1000_check_reset_block_ich8lan,
.commit_phy = NULL,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..a3e64ae 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1409,7 +1409,7 @@ static struct e1000_mac_operations e1000_mac_ops_82575 = {
.get_speed_and_duplex = igb_get_speed_and_duplex_copper,
};

-static struct e1000_phy_operations e1000_phy_ops_82575 = {
+static const struct e1000_phy_operations e1000_phy_ops_82575 = {
.acquire = igb_acquire_phy_82575,
.get_cfg_done = igb_get_cfg_done_82575,
.release = igb_release_phy_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..326e0e7 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -311,7 +311,7 @@ struct e1000_nvm_operations {
struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

2009-12-05 00:01:18

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 07/31] Constify struct e1000_nvm_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_nvm_operations.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 2 +-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/hw.h | 16 ++++++++--------
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 12 ++++++------
7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..2a2355f 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1725,7 +1725,7 @@ static struct e1000_phy_operations e82_phy_ops_bm = {
.cfg_on_link_up = NULL,
};

-static struct e1000_nvm_operations e82571_nvm_ops = {
+static const struct e1000_nvm_operations e82571_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_82571,
.read_nvm = e1000e_read_nvm_eerd,
.release_nvm = e1000_release_nvm_82571,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..bcdcfb1 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -377,7 +377,7 @@ struct e1000_info {
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

/* hardware capability, feature, and workaround flags */
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..a980900 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1400,7 +1400,7 @@ static struct e1000_phy_operations es2_phy_ops = {
.cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
};

-static struct e1000_nvm_operations es2_nvm_ops = {
+static const struct e1000_nvm_operations es2_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_80003es2lan,
.read_nvm = e1000e_read_nvm_eerd,
.release_nvm = e1000_release_nvm_80003es2lan,
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index aaea41e..f7f181f 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -776,13 +776,13 @@ struct e1000_phy_operations {

/* Function pointers for the NVM. */
struct e1000_nvm_operations {
- s32 (*acquire_nvm)(struct e1000_hw *);
- s32 (*read_nvm)(struct e1000_hw *, u16, u16, u16 *);
- void (*release_nvm)(struct e1000_hw *);
- s32 (*update_nvm)(struct e1000_hw *);
- s32 (*valid_led_default)(struct e1000_hw *, u16 *);
- s32 (*validate_nvm)(struct e1000_hw *);
- s32 (*write_nvm)(struct e1000_hw *, u16, u16, u16 *);
+ s32 (* const acquire_nvm)(struct e1000_hw *);
+ s32 (* const read_nvm)(struct e1000_hw *, u16, u16, u16 *);
+ void (* const release_nvm)(struct e1000_hw *);
+ s32 (* const update_nvm)(struct e1000_hw *);
+ s32 (* const valid_led_default)(struct e1000_hw *, u16 *);
+ s32 (* const validate_nvm)(struct e1000_hw *);
+ s32 (* const write_nvm)(struct e1000_hw *, u16, u16, u16 *);
};

struct e1000_mac_info {
@@ -856,7 +856,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
- struct e1000_nvm_operations ops;
+ const struct e1000_nvm_operations ops;

enum e1000_nvm_type type;
enum e1000_nvm_override override;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..8835afa 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3485,7 +3485,7 @@ static struct e1000_phy_operations ich8_phy_ops = {
.write_phy_reg = e1000e_write_phy_reg_igp,
};

-static struct e1000_nvm_operations ich8_nvm_ops = {
+static const struct e1000_nvm_operations ich8_nvm_ops = {
.acquire_nvm = e1000_acquire_nvm_ich8lan,
.read_nvm = e1000_read_nvm_ich8lan,
.release_nvm = e1000_release_nvm_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..f62d4e1 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1415,7 +1415,7 @@ static struct e1000_phy_operations e1000_phy_ops_82575 = {
.release = igb_release_phy_82575,
};

-static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
+static const struct e1000_nvm_operations e1000_nvm_ops_82575 = {
.acquire = igb_acquire_nvm_82575,
.read = igb_read_nvm_eerd,
.release = igb_release_nvm_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..c31e6b2 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -302,17 +302,17 @@ struct e1000_phy_operations {
};

struct e1000_nvm_operations {
- s32 (*acquire)(struct e1000_hw *);
- s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
- void (*release)(struct e1000_hw *);
- s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
+ s32 (* const acquire)(struct e1000_hw *);
+ s32 (* const read)(struct e1000_hw *, u16, u16, u16 *);
+ void (* const release)(struct e1000_hw *);
+ s32 (* const write)(struct e1000_hw *, u16, u16, u16 *);
};

struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

extern const struct e1000_info e1000_82575_info;
@@ -397,7 +397,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
- struct e1000_nvm_operations ops;
+ const struct e1000_nvm_operations ops;

enum e1000_nvm_type type;
enum e1000_nvm_override override;

2009-12-05 00:01:23

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_mac_operations with some exceptions.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 3 ++-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 3 ++-
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 2 +-
6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d1e0563..16ffb11 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const */
struct e1000_mac_operations *func = &mac->ops;
u32 swsm = 0;
u32 swsm2 = 0;
@@ -1656,7 +1657,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
temp = er32(ICRXDMTC);
}

-static struct e1000_mac_operations e82571_mac_ops = {
+static const struct e1000_mac_operations e82571_mac_ops = {
/* .check_mng_mode: mac type dependent */
/* .check_for_link: media type dependent */
.id_led_init = e1000e_id_led_init,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3e187b0..933f5da 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -375,7 +375,7 @@ struct e1000_info {
u32 pba;
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index ae5d736..06d47e0 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -207,6 +207,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const */
struct e1000_mac_operations *func = &mac->ops;

/* Set media type */
@@ -1365,7 +1366,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
temp = er32(ICRXDMTC);
}

-static struct e1000_mac_operations es2_mac_ops = {
+static const struct e1000_mac_operations es2_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000e_check_mng_mode_generic,
/* check_for_link dependent on media type */
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index eff3f47..3e0065b 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3451,7 +3451,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
}
}

-static struct e1000_mac_operations ich8_mac_ops = {
+static const struct e1000_mac_operations ich8_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000_check_mng_mode_ich8lan,
.check_for_link = e1000_check_for_copper_link_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772..3d5794f 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1400,7 +1400,7 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
wr32(E1000_VT_CTL, vt_ctl);
}

-static struct e1000_mac_operations e1000_mac_ops_82575 = {
+static const struct e1000_mac_operations e1000_mac_ops_82575 = {
.reset_hw = igb_reset_hw_82575,
.init_hw = igb_init_hw_82575,
.check_for_link = igb_check_for_link_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 119869b..d58b7e5 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -310,7 +310,7 @@ struct e1000_nvm_operations {

struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

2009-12-05 00:02:24

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

From: Emese Revfy <[email protected]>

Constify struct sysfs_ops.
Per Dave Miller's suggestion, resend with proper CC list and patch format.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/kernel/topology.c | 2 +-
arch/powerpc/kernel/cacheinfo.c | 2 +-
arch/sh/kernel/cpu/sh4/sq.c | 2 +-
arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +-
arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +-
block/blk-integrity.c | 2 +-
block/blk-sysfs.c | 2 +-
block/elevator.c | 2 +-
drivers/base/bus.c | 4 ++--
drivers/base/class.c | 2 +-
drivers/base/core.c | 2 +-
drivers/base/sys.c | 4 ++--
drivers/block/pktcdvd.c | 2 +-
drivers/cpufreq/cpufreq.c | 2 +-
drivers/cpuidle/sysfs.c | 4 ++--
drivers/dma/ioat/dma.c | 2 +-
drivers/dma/ioat/dma.h | 2 +-
drivers/edac/edac_device_sysfs.c | 6 +++---
drivers/edac/edac_mc_sysfs.c | 4 ++--
drivers/edac/edac_pci_sysfs.c | 4 ++--
drivers/firmware/edd.c | 2 +-
drivers/firmware/efivars.c | 2 +-
drivers/firmware/iscsi_ibft.c | 2 +-
drivers/firmware/memmap.c | 2 +-
drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
drivers/gpu/drm/ttm/ttm_memory.c | 2 +-
drivers/infiniband/core/cm.c | 2 +-
drivers/infiniband/core/sysfs.c | 2 +-
drivers/md/dm-sysfs.c | 2 +-
drivers/md/md.c | 4 ++--
drivers/net/ibmveth.c | 2 +-
drivers/net/iseries_veth.c | 4 ++--
drivers/parisc/pdc_stable.c | 2 +-
drivers/pci/hotplug/fakephp.c | 2 +-
drivers/pci/slot.c | 2 +-
drivers/uio/uio.c | 4 ++--
drivers/uwb/wlp/sysfs.c | 3 +--
drivers/xen/sys-hypervisor.c | 2 +-
fs/btrfs/sysfs.c | 4 ++--
fs/dlm/lockspace.c | 2 +-
fs/ext4/super.c | 2 +-
fs/gfs2/sys.c | 2 +-
fs/ocfs2/cluster/masklog.c | 2 +-
fs/sysfs/file.c | 8 ++++----
include/linux/kobject.h | 4 ++--
include/linux/sysfs.h | 4 ++--
kernel/params.c | 2 +-
lib/kobject.c | 2 +-
mm/slub.c | 2 +-
net/bridge/br_private.h | 2 +-
net/bridge/br_sysfs_if.c | 2 +-
samples/kobject/kset-example.c | 2 +-
52 files changed, 68 insertions(+), 69 deletions(-)

diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 8f06035..b3a5818 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
return ret;
}

-static struct sysfs_ops cache_sysfs_ops = {
+static const struct sysfs_ops cache_sysfs_ops = {
.show = cache_show
};

diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index bb37b1d..01fe9ce 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = {
&cache_assoc_attr,
};

-static struct sysfs_ops cache_index_ops = {
+static const struct sysfs_ops cache_index_ops = {
.show = cache_index_show,
};

diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 8a8a993..7b3079b 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -327,7 +327,7 @@ static struct attribute *sq_sysfs_attrs[] = {
NULL,
};

-static struct sysfs_ops sq_sysfs_ops = {
+static const struct sysfs_ops sq_sysfs_ops = {
.show = sq_sysfs_show,
.store = sq_sysfs_store,
};
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 804c40e..dc7f8a7 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -860,7 +860,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = show,
.store = store,
};
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 83a3d1f..cda932c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -388,7 +388,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops threshold_ops = {
+static const struct sysfs_ops threshold_ops = {
.show = show,
.store = store,
};
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 15c6308..96e83c2 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -278,7 +278,7 @@ static struct attribute *integrity_attrs[] = {
NULL,
};

-static struct sysfs_ops integrity_ops = {
+static const struct sysfs_ops integrity_ops = {
.show = &integrity_attr_show,
.store = &integrity_attr_store,
};
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 8a6d81a..dc3e40b 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -414,7 +414,7 @@ static void blk_release_queue(struct kobject *kobj)
kmem_cache_free(blk_requestq_cachep, q);
}

-static struct sysfs_ops queue_sysfs_ops = {
+static const struct sysfs_ops queue_sysfs_ops = {
.show = queue_attr_show,
.store = queue_attr_store,
};
diff --git a/block/elevator.c b/block/elevator.c
index a847046..75a1746 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -889,7 +889,7 @@ elv_attr_store(struct kobject *kobj, struct attribute *attr,
return error;
}

-static struct sysfs_ops elv_sysfs_ops = {
+static const struct sysfs_ops elv_sysfs_ops = {
.show = elv_attr_show,
.store = elv_attr_store,
};
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 63c143e..66ddfea 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -70,7 +70,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops driver_sysfs_ops = {
+static const struct sysfs_ops driver_sysfs_ops = {
.show = drv_attr_show,
.store = drv_attr_store,
};
@@ -115,7 +115,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops bus_sysfs_ops = {
+static const struct sysfs_ops bus_sysfs_ops = {
.show = bus_attr_show,
.store = bus_attr_store,
};
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 161746d..c2359c8 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -61,7 +61,7 @@ static void class_release(struct kobject *kobj)
"be careful\n", class->name);
}

-static struct sysfs_ops class_sysfs_ops = {
+static const struct sysfs_ops class_sysfs_ops = {
.show = class_attr_show,
.store = class_attr_store,
};
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6bee6af..35aeae5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -93,7 +93,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops dev_sysfs_ops = {
+static const struct sysfs_ops dev_sysfs_ops = {
.show = dev_attr_show,
.store = dev_attr_store,
};
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 0d90390..dd710ca 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -54,7 +54,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = sysdev_show,
.store = sysdev_store,
};
@@ -104,7 +104,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops sysfs_class_ops = {
+static const struct sysfs_ops sysfs_class_ops = {
.show = sysdev_class_show,
.store = sysdev_class_store,
};
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 2ddf03a..44eab68 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -284,7 +284,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
return len;
}

-static struct sysfs_ops kobj_pkt_ops = {
+static const struct sysfs_ops kobj_pkt_ops = {
.show = kobj_pkt_show,
.store = kobj_pkt_store
};
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index ff57c40..76da29f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -750,7 +750,7 @@ static void cpufreq_sysfs_release(struct kobject *kobj)
complete(&policy->kobj_unregister);
}

-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
.show = show,
.store = store,
};
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 97b0038..aaaa360 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -191,7 +191,7 @@ static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr,
return ret;
}

-static struct sysfs_ops cpuidle_sysfs_ops = {
+static const struct sysfs_ops cpuidle_sysfs_ops = {
.show = cpuidle_show,
.store = cpuidle_store,
};
@@ -277,7 +277,7 @@ static ssize_t cpuidle_state_show(struct kobject * kobj,
return ret;
}

-static struct sysfs_ops cpuidle_state_sysfs_ops = {
+static const struct sysfs_ops cpuidle_state_sysfs_ops = {
.show = cpuidle_state_show,
};

diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index c524d36..fc2d0b6 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -1146,7 +1146,7 @@ ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
return entry->show(&chan->common, page);
}

-struct sysfs_ops ioat_sysfs_ops = {
+const struct sysfs_ops ioat_sysfs_ops = {
.show = ioat_attr_show,
};

diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index 45edde9..c72e7fe 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -329,7 +329,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
unsigned long *phys_complete);
void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
void ioat_kobject_del(struct ioatdma_device *device);
-extern struct sysfs_ops ioat_sysfs_ops;
+extern const struct sysfs_ops ioat_sysfs_ops;
extern struct ioat_sysfs_entry ioat_version_attr;
extern struct ioat_sysfs_entry ioat_cap_attr;
#endif /* IOATDMA_H */
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 5376457..5fdedbc 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -137,7 +137,7 @@ static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
}

/* edac_dev file operations for an 'ctl_info' */
-static struct sysfs_ops device_ctl_info_ops = {
+static const struct sysfs_ops device_ctl_info_ops = {
.show = edac_dev_ctl_info_show,
.store = edac_dev_ctl_info_store
};
@@ -373,7 +373,7 @@ static ssize_t edac_dev_instance_store(struct kobject *kobj,
}

/* edac_dev file operations for an 'instance' */
-static struct sysfs_ops device_instance_ops = {
+static const struct sysfs_ops device_instance_ops = {
.show = edac_dev_instance_show,
.store = edac_dev_instance_store
};
@@ -476,7 +476,7 @@ static ssize_t edac_dev_block_store(struct kobject *kobj,
}

/* edac_dev file operations for a 'block' */
-static struct sysfs_ops device_block_ops = {
+static const struct sysfs_ops device_block_ops = {
.show = edac_dev_block_show,
.store = edac_dev_block_store
};
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index e1d4ce0..88840e9 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -245,7 +245,7 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
}

-static struct sysfs_ops csrowfs_ops = {
+static const struct sysfs_ops csrowfs_ops = {
.show = csrowdev_show,
.store = csrowdev_store
};
@@ -575,7 +575,7 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
}

/* Intermediate show/store table */
-static struct sysfs_ops mci_ops = {
+static const struct sysfs_ops mci_ops = {
.show = mcidev_show,
.store = mcidev_store
};
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 422728c..79217da 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -121,7 +121,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj,
}

/* fs_ops table */
-static struct sysfs_ops pci_instance_ops = {
+static const struct sysfs_ops pci_instance_ops = {
.show = edac_pci_instance_show,
.store = edac_pci_instance_store
};
@@ -261,7 +261,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
return -EIO;
}

-static struct sysfs_ops edac_pci_sysfs_ops = {
+static const struct sysfs_ops edac_pci_sysfs_ops = {
.show = edac_pci_dev_show,
.store = edac_pci_dev_store
};
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 9e4f59d..110e24e 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -122,7 +122,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
return ret;
}

-static struct sysfs_ops edd_attr_ops = {
+static const struct sysfs_ops edd_attr_ops = {
.show = edd_attr_show,
};

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index f4f709d..082f06e 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -362,7 +362,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops efivar_attr_ops = {
+static const struct sysfs_ops efivar_attr_ops = {
.show = efivar_attr_show,
.store = efivar_attr_store,
};
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 051d1eb..0a5d4e7 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -525,7 +525,7 @@ static ssize_t ibft_show_attribute(struct kobject *kobj,
return ret;
}

-static struct sysfs_ops ibft_attr_ops = {
+static const struct sysfs_ops ibft_attr_ops = {
.show = ibft_show_attribute,
};

diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 56f9234..8c58c7b 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -74,7 +74,7 @@ static struct attribute *def_attrs[] = {
NULL
};

-static struct sysfs_ops memmap_attr_ops = {
+static const struct sysfs_ops memmap_attr_ops = {
.show = memmap_attr_show,
};

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 87c0625..d9a23ef 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -67,7 +67,7 @@ static struct attribute *ttm_bo_global_attrs[] = {
NULL
};

-static struct sysfs_ops ttm_bo_global_ops = {
+static const struct sysfs_ops ttm_bo_global_ops = {
.show = &ttm_bo_global_show
};

diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 072c281..d8ef483 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -152,7 +152,7 @@ static struct attribute *ttm_mem_zone_attrs[] = {
NULL
};

-static struct sysfs_ops ttm_mem_zone_ops = {
+static const struct sysfs_ops ttm_mem_zone_ops = {
.show = &ttm_mem_zone_show,
.store = &ttm_mem_zone_store
};
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 5130fc5..764787e 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3597,7 +3597,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
atomic_long_read(&group->counter[cm_attr->index]));
}

-static struct sysfs_ops cm_counter_ops = {
+static const struct sysfs_ops cm_counter_ops = {
.show = cm_show_counter
};

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 158a214..1558bb7 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -79,7 +79,7 @@ static ssize_t port_attr_show(struct kobject *kobj,
return port_attr->show(p, port_attr, buf);
}

-static struct sysfs_ops port_sysfs_ops = {
+static const struct sysfs_ops port_sysfs_ops = {
.show = port_attr_show
};

diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c
index 4b04590..13a77b2 100644
--- a/drivers/md/dm-sysfs.c
+++ b/drivers/md/dm-sysfs.c
@@ -75,7 +75,7 @@ static struct attribute *dm_attrs[] = {
NULL,
};

-static struct sysfs_ops dm_sysfs_ops = {
+static const struct sysfs_ops dm_sysfs_ops = {
.show = dm_attr_show,
};

diff --git a/drivers/md/md.c b/drivers/md/md.c
index b182f86..431d54d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2505,7 +2505,7 @@ static void rdev_free(struct kobject *ko)
mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj);
kfree(rdev);
}
-static struct sysfs_ops rdev_sysfs_ops = {
+static const struct sysfs_ops rdev_sysfs_ops = {
.show = rdev_attr_show,
.store = rdev_attr_store,
};
@@ -3875,7 +3875,7 @@ static void md_free(struct kobject *ko)
kfree(mddev);
}

-static struct sysfs_ops md_sysfs_ops = {
+static const struct sysfs_ops md_sysfs_ops = {
.show = md_attr_show,
.store = md_attr_store,
};
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 5862282..7cce8cb 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1577,7 +1577,7 @@ static struct attribute * veth_pool_attrs[] = {
NULL,
};

-static struct sysfs_ops veth_pool_ops = {
+static const struct sysfs_ops veth_pool_ops = {
.show = veth_pool_show,
.store = veth_pool_store,
};
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index aa7286b..a61394f 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -384,7 +384,7 @@ static struct attribute *veth_cnx_default_attrs[] = {
NULL
};

-static struct sysfs_ops veth_cnx_sysfs_ops = {
+static const struct sysfs_ops veth_cnx_sysfs_ops = {
.show = veth_cnx_attribute_show
};

@@ -441,7 +441,7 @@ static struct attribute *veth_port_default_attrs[] = {
NULL
};

-static struct sysfs_ops veth_port_sysfs_ops = {
+static const struct sysfs_ops veth_port_sysfs_ops = {
.show = veth_port_attribute_show
};

diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 13a64bc..ad62835 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -481,7 +481,7 @@ pdcspath_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static struct sysfs_ops pdcspath_attr_ops = {
+static const struct sysfs_ops pdcspath_attr_ops = {
.show = pdcspath_attr_show,
.store = pdcspath_attr_store,
};
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 6151389..0a894ef 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -73,7 +73,7 @@ static void legacy_release(struct kobject *kobj)
}

static struct kobj_type legacy_ktype = {
- .sysfs_ops = &(struct sysfs_ops){
+ .sysfs_ops = &(const struct sysfs_ops){
.store = legacy_store, .show = legacy_show
},
.release = &legacy_release,
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 8c02b6c..5584d8e 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -29,7 +29,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj,
return attribute->store ? attribute->store(slot, buf, len) : -EIO;
}

-static struct sysfs_ops pci_slot_sysfs_ops = {
+static const struct sysfs_ops pci_slot_sysfs_ops = {
.show = pci_slot_attr_show,
.store = pci_slot_attr_store,
};
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index e941367..4de382a 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -129,7 +129,7 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
return entry->show(mem, buf);
}

-static struct sysfs_ops map_sysfs_ops = {
+static const struct sysfs_ops map_sysfs_ops = {
.show = map_type_show,
};

@@ -217,7 +217,7 @@ static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr,
return entry->show(port, buf);
}

-static struct sysfs_ops portio_sysfs_ops = {
+static const struct sysfs_ops portio_sysfs_ops = {
.show = portio_type_show,
};

diff --git a/drivers/uwb/wlp/sysfs.c b/drivers/uwb/wlp/sysfs.c
index 0370399..6627c94 100644
--- a/drivers/uwb/wlp/sysfs.c
+++ b/drivers/uwb/wlp/sysfs.c
@@ -615,8 +615,7 @@ ssize_t wlp_wss_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-static
-struct sysfs_ops wss_sysfs_ops = {
+static const struct sysfs_ops wss_sysfs_ops = {
.show = wlp_wss_attr_show,
.store = wlp_wss_attr_store,
};
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
index 88a60e0..6783cc2 100644
--- a/drivers/xen/sys-hypervisor.c
+++ b/drivers/xen/sys-hypervisor.c
@@ -425,7 +425,7 @@ static ssize_t hyp_sysfs_store(struct kobject *kobj,
return 0;
}

-static struct sysfs_ops hyp_sysfs_ops = {
+static const struct sysfs_ops hyp_sysfs_ops = {
.show = hyp_sysfs_show,
.store = hyp_sysfs_store,
};
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index a240b6f..4ce16ef 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -164,12 +164,12 @@ static void btrfs_root_release(struct kobject *kobj)
complete(&root->kobj_unregister);
}

-static struct sysfs_ops btrfs_super_attr_ops = {
+static const struct sysfs_ops btrfs_super_attr_ops = {
.show = btrfs_super_attr_show,
.store = btrfs_super_attr_store,
};

-static struct sysfs_ops btrfs_root_attr_ops = {
+static const struct sysfs_ops btrfs_root_attr_ops = {
.show = btrfs_root_attr_show,
.store = btrfs_root_attr_store,
};
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index d489fcc..5b0bd1e 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -148,7 +148,7 @@ static void lockspace_kobj_release(struct kobject *k)
kfree(ls);
}

-static struct sysfs_ops dlm_attr_ops = {
+static const struct sysfs_ops dlm_attr_ops = {
.show = dlm_attr_show,
.store = dlm_attr_store,
};
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d4ca92a..b0594f3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2251,7 +2251,7 @@ static void ext4_sb_release(struct kobject *kobj)
}


-static struct sysfs_ops ext4_attr_ops = {
+static const struct sysfs_ops ext4_attr_ops = {
.show = ext4_attr_show,
.store = ext4_attr_store,
};
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 4463297..cc946e8 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -49,7 +49,7 @@ static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
return a->store ? a->store(sdp, buf, len) : len;
}

-static struct sysfs_ops gfs2_attr_ops = {
+static const struct sysfs_ops gfs2_attr_ops = {
.show = gfs2_attr_show,
.store = gfs2_attr_store,
};
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index 1cd2934..880b5d2 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -135,7 +135,7 @@ static ssize_t mlog_store(struct kobject *obj, struct attribute *attr,
return mlog_mask_store(mlog_attr->mask, buf, count);
}

-static struct sysfs_ops mlog_attr_ops = {
+static const struct sysfs_ops mlog_attr_ops = {
.show = mlog_show,
.store = mlog_store,
};
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index f5ea468..b59b2e4 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -53,7 +53,7 @@ struct sysfs_buffer {
size_t count;
loff_t pos;
char * page;
- struct sysfs_ops * ops;
+ const struct sysfs_ops * ops;
struct mutex mutex;
int needs_read_fill;
int event;
@@ -75,7 +75,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
{
struct sysfs_dirent *attr_sd = dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
- struct sysfs_ops * ops = buffer->ops;
+ const struct sysfs_ops * ops = buffer->ops;
int ret = 0;
ssize_t count;

@@ -199,7 +199,7 @@ flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t
{
struct sysfs_dirent *attr_sd = dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
- struct sysfs_ops * ops = buffer->ops;
+ const struct sysfs_ops * ops = buffer->ops;
int rc;

/* need attr_sd for attr and ops, its parent for kobj */
@@ -335,7 +335,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
struct sysfs_buffer *buffer;
- struct sysfs_ops *ops;
+ const struct sysfs_ops *ops;
int error = -EACCES;
char *p;

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 58ae8e0..072cee4 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -106,7 +106,7 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);

struct kobj_type {
void (*release)(struct kobject *kobj);
- struct sysfs_ops *sysfs_ops;
+ const struct sysfs_ops *sysfs_ops;
struct attribute **default_attrs;
};

@@ -132,7 +132,7 @@ struct kobj_attribute {
const char *buf, size_t count);
};

-extern struct sysfs_ops kobj_sysfs_ops;
+extern const struct sysfs_ops kobj_sysfs_ops;

/**
* struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 9d68fed..71f02cc 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -75,8 +75,8 @@ struct bin_attribute {
};

struct sysfs_ops {
- ssize_t (*show)(struct kobject *, struct attribute *,char *);
- ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
+ ssize_t (* const show)(struct kobject *, struct attribute *,char *);
+ ssize_t (* const store)(struct kobject *,struct attribute *,const char *, size_t);
};

struct sysfs_dirent;
diff --git a/kernel/params.c b/kernel/params.c
index d656c27..8b060d0 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -725,7 +725,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
return ret;
}

-static struct sysfs_ops module_sysfs_ops = {
+static const struct sysfs_ops module_sysfs_ops = {
.show = module_attr_show,
.store = module_attr_store,
};
diff --git a/lib/kobject.c b/lib/kobject.c
index b512b74..6567393 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -700,7 +700,7 @@ static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
return ret;
}

-struct sysfs_ops kobj_sysfs_ops = {
+const struct sysfs_ops kobj_sysfs_ops = {
.show = kobj_attr_show,
.store = kobj_attr_store,
};
diff --git a/mm/slub.c b/mm/slub.c
index 4996fc7..7c047ba 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4503,7 +4503,7 @@ static void kmem_cache_release(struct kobject *kobj)
kfree(s);
}

-static struct sysfs_ops slab_sysfs_ops = {
+static const struct sysfs_ops slab_sysfs_ops = {
.show = slab_attr_show,
.store = slab_attr_store,
};
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 2114e45..c53bdd9 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -254,7 +254,7 @@ extern void br_ifinfo_notify(int event, struct net_bridge_port *port);

#ifdef CONFIG_SYSFS
/* br_sysfs_if.c */
-extern struct sysfs_ops brport_sysfs_ops;
+extern const struct sysfs_ops brport_sysfs_ops;
extern int br_sysfs_addif(struct net_bridge_port *p);

/* br_sysfs_br.c */
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 820643a..ce77fb3 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -220,7 +220,7 @@ static ssize_t brport_store(struct kobject * kobj,
return ret;
}

-struct sysfs_ops brport_sysfs_ops = {
+const struct sysfs_ops brport_sysfs_ops = {
.show = brport_show,
.store = brport_store,
};
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
index 45b7d56..19e828c 100644
--- a/samples/kobject/kset-example.c
+++ b/samples/kobject/kset-example.c
@@ -87,7 +87,7 @@ static ssize_t foo_attr_store(struct kobject *kobj,
}

/* Our custom sysfs_ops that we will associate with our ktype later on */
-static struct sysfs_ops foo_sysfs_ops = {
+static const struct sysfs_ops foo_sysfs_ops = {
.show = foo_attr_show,
.store = foo_attr_store,
};

2009-12-05 00:08:41

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH 02/31] Constify struct address_space_operations for 2.6.32 v1

On Fri, Dec 04, 2009 at 11:08:09PM +0100, Emese Revfy wrote:
> struct address_space_operations {
> - int (*writepage)(struct page *page, struct writeback_control *wbc);
> - int (*readpage)(struct file *, struct page *);
> - void (*sync_page)(struct page *);
> + int (* const writepage)(struct page *page, struct writeback_control *wbc);
> + int (* const readpage)(struct file *, struct page *);
> + void (* const sync_page)(struct page *);

Umm. What effect does this have? Aren't functions implicitly constant?
What changes as a result of this patch?

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."

2009-12-05 00:10:59

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct file_operations with some exceptions.
> Per Dave Miller's suggestion, resend with proper CC list and patch format.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> drivers/acpi/battery.c | 2 +-
> drivers/char/pty.c | 16 +++++++++---
> drivers/char/tty_io.c | 28 ++++-----------------
> drivers/media/dvb/dvb-core/dvbdev.c | 1 +
> drivers/net/wireless/b43/debugfs.c | 2 +-
> drivers/net/wireless/b43legacy/debugfs.c | 2 +-
> drivers/net/wireless/libertas/debugfs.c | 2 +-
> drivers/staging/b3dfg/b3dfg.c | 2 +-
> drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
> drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
> drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
> drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
> drivers/staging/dream/qdsp5/audio_in.c | 4 +-
> drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
> drivers/staging/dream/qdsp5/audio_out.c | 4 +-
> drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
> drivers/staging/dream/qdsp5/snd.c | 2 +-
> drivers/staging/dream/smd/smd_qmi.c | 2 +-
> drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 +-
> drivers/staging/panel/panel.c | 4 +-
> drivers/staging/poch/poch.c | 2 +-
> drivers/staging/sep/sep_driver.c | 2 +-
> drivers/staging/vme/devices/vme_user.c | 2 +-
> fs/fuse/cuse.c | 20 +++++++++------
> fs/fuse/dev.c | 8 +++---
> fs/fuse/fuse_i.h | 10 ++++++++
> include/linux/tty.h | 14 ++++++++++-
> include/net/tcp.h | 1 +
> include/net/udp.h | 1 +
> kernel/trace/trace_events.c | 2 +
> virt/kvm/kvm_main.c | 3 ++
> 31 files changed, 89 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 3f4602b..2e41d36 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
> }
>
> static struct battery_file {
> - struct file_operations ops;
> + const struct file_operations ops;
> mode_t mode;
> const char *name;
> } acpi_battery_file[] = {
> diff --git a/drivers/char/pty.c b/drivers/char/pty.c
> index 62f282e..d39c67b 100644
> --- a/drivers/char/pty.c
> +++ b/drivers/char/pty.c
> @@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
> return ret;
> }
>
> -static struct file_operations ptmx_fops;
> +static const struct file_operations ptmx_fops = {
> + .llseek = no_llseek,
> + .read = tty_read,
> + .write = tty_write,
> + .poll = tty_poll,
> + .unlocked_ioctl = tty_ioctl,
> + .compat_ioctl = tty_compat_ioctl,
> + .open = ptmx_open,
> + .release = tty_release,
> + .fasync = tty_fasync,
> +};

You just made these functions all global, for no real good reason. Why
did you do this?

confused,

greg k-h

2009-12-05 00:34:58

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 02/31] Constify struct address_space_operations for 2.6.32 v1

Matthew Wilcox wrote:
> On Fri, Dec 04, 2009 at 11:08:09PM +0100, Emese Revfy wrote:
>> struct address_space_operations {
>> - int (*writepage)(struct page *page, struct writeback_control *wbc);
>> - int (*readpage)(struct file *, struct page *);
>> - void (*sync_page)(struct page *);
>> + int (* const writepage)(struct page *page, struct writeback_control *wbc);
>> + int (* const readpage)(struct file *, struct page *);
>> + void (* const sync_page)(struct page *);
>
> Umm. What effect does this have?
> What changes as a result of this patch?

My idea was that since all variables of this type are const, we might
as well have the compiler enforce it for the future if you think that
these fields should not be writable at all.

> Aren't functions implicitly constant?

They are, but these are function pointer fields in a structure, not
the functions themselves.

--
Emese

2009-12-05 00:40:50

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

Hi Emese,

On Sat, 05 Dec 2009 01:03:03 +0100 Emese Revfy <[email protected]> wrote:
>
> --- a/drivers/net/e1000e/82571.c
> +++ b/drivers/net/e1000e/82571.c
> @@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
> {
> struct e1000_hw *hw = &adapter->hw;
> struct e1000_mac_info *mac = &hw->mac;
> + /* cannot be const */
> struct e1000_mac_operations *func = &mac->ops;

Adding to the comment to say why it can't be const may allow us to fix
this later ...

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (606.00 B)
(No filename) (198.00 B)
Download all attachments

2009-12-05 00:59:39

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Hi Emese,

On Fri, 04 Dec 2009 23:14:08 +0100 Emese Revfy <[email protected]> wrote:
>
> --- a/arch/powerpc/kernel/vio.c
> +++ b/arch/powerpc/kernel/vio.c
> @@ -601,6 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
> vio_cmo_dealloc(viodev, alloc_size);
> }
>
> +/* cannot be const */
> struct dma_map_ops vio_dma_mapping_ops = {

The problem with leaving this not const is that a pointer to it is later
assigned to an archdata::dma_ops which you have made into a const pointer
earlier in this patch. This will generate a warning which is fatal in
arch/powerpc as we compile that directory with -Werror.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (733.00 B)
(No filename) (198.00 B)
Download all attachments

2009-12-05 01:17:10

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

Stephen Rothwell wrote:
> Hi Emese,
>
> On Sat, 05 Dec 2009 01:03:03 +0100 Emese Revfy <[email protected]> wrote:
>> --- a/drivers/net/e1000e/82571.c
>> +++ b/drivers/net/e1000e/82571.c
>> @@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
>> {
>> struct e1000_hw *hw = &adapter->hw;
>> struct e1000_mac_info *mac = &hw->mac;
>> + /* cannot be const */
>> struct e1000_mac_operations *func = &mac->ops;
>
> Adding to the comment to say why it can't be const may allow us to fix
> this later ...

Ok, in the next patch series I will explain each case.

2009-12-05 01:20:18

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Hi Emese,

On Sat, 5 Dec 2009 11:59:36 +1100 Stephen Rothwell <[email protected]> wrote:
>
> On Fri, 04 Dec 2009 23:14:08 +0100 Emese Revfy <[email protected]> wrote:
> >
> > --- a/arch/powerpc/kernel/vio.c
> > +++ b/arch/powerpc/kernel/vio.c
> > @@ -601,6 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
> > vio_cmo_dealloc(viodev, alloc_size);
> > }
> >
> > +/* cannot be const */
> > struct dma_map_ops vio_dma_mapping_ops = {
>
> The problem with leaving this not const is that a pointer to it is later
> assigned to an archdata::dma_ops which you have made into a const pointer
> earlier in this patch. This will generate a warning which is fatal in
> arch/powerpc as we compile that directory with -Werror.

Actually with a little more work, it can be made const. The only
assignment to it can be put in the initialiser instead ... As an aside,
it should also be made static.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (0.99 kB)
(No filename) (198.00 B)
Download all attachments

2009-12-05 01:21:25

by Jeff Kirsher

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for 2.6.32 v1

2009/12/4 Emese Revfy <[email protected]>:
> Stephen Rothwell wrote:
>> Hi Emese,
>>
>> On Sat, 05 Dec 2009 01:03:03 +0100 Emese Revfy <[email protected]> wrote:
>>> --- a/drivers/net/e1000e/82571.c
>>> +++ b/drivers/net/e1000e/82571.c
>>> @@ -212,6 +212,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
>>>  {
>>>      struct e1000_hw *hw = &adapter->hw;
>>>      struct e1000_mac_info *mac = &hw->mac;
>>> +    /* cannot be const */
>>>      struct e1000_mac_operations *func = &mac->ops;
>>
>> Adding to the comment to say why it can't be const may allow us to fix
>> this later ...
>
> Ok, in the next patch series I will explain each case.
> --

Also, please sync up your patches with what is in Dave's net-next-2.6
tree, because some of the changes made no longer apply since the code
was either changed or removed.

--
Cheers,
Jeff

2009-12-05 01:58:58

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Stephen Rothwell wrote:
> Hi Emese,
>
> On Sat, 5 Dec 2009 11:59:36 +1100 Stephen Rothwell <[email protected]> wrote:
>> On Fri, 04 Dec 2009 23:14:08 +0100 Emese Revfy <[email protected]> wrote:
>>> --- a/arch/powerpc/kernel/vio.c
>>> +++ b/arch/powerpc/kernel/vio.c
>>> @@ -601,6 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
>>> vio_cmo_dealloc(viodev, alloc_size);
>>> }
>>>
>>> +/* cannot be const */
>>> struct dma_map_ops vio_dma_mapping_ops = {
>> The problem with leaving this not const is that a pointer to it is later
>> assigned to an archdata::dma_ops which you have made into a const pointer
>> earlier in this patch. This will generate a warning which is fatal in
>> arch/powerpc as we compile that directory with -Werror.
>
> Actually with a little more work, it can be made const. The only
> assignment to it can be put in the initialiser instead ... As an aside,
> it should also be made static.

Ok, I made the changes, I also removed the vio_cmo_set_dma_ops function
because I think it is now unnecessary.

From: Emese Revfy <[email protected]>

Constify struct dma_map_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/hp/common/hwsw_iommu.c | 4 +-
arch/ia64/hp/common/sba_iommu.c | 4 +-
arch/ia64/include/asm/dma-mapping.h | 10 ++++----
arch/ia64/include/asm/machvec.h | 4 +-
arch/ia64/kernel/dma-mapping.c | 4 +-
arch/ia64/kernel/pci-dma.c | 2 +-
arch/ia64/kernel/pci-swiotlb.c | 2 +-
arch/ia64/sn/pci/pci_dma.c | 2 +-
arch/powerpc/include/asm/device.h | 2 +-
arch/powerpc/include/asm/dma-mapping.h | 18 ++++++++--------
arch/powerpc/include/asm/iommu.h | 3 ++
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-iommu.c | 4 +-
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 ++--
arch/powerpc/kernel/vio.c | 13 ++---------
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 +-
arch/sparc/include/asm/dma-mapping.h | 8 +++---
arch/sparc/kernel/iommu.c | 4 +-
arch/sparc/kernel/ioport.c | 6 ++--
arch/sparc/kernel/pci_sun4v.c | 2 +-
arch/x86/include/asm/device.h | 2 +-
arch/x86/include/asm/dma-mapping.h | 10 ++++----
arch/x86/include/asm/iommu.h | 2 +-
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/pci-calgary_64.c | 2 +-
arch/x86/kernel/pci-dma.c | 4 +-
arch/x86/kernel/pci-gart_64.c | 2 +-
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 2 +-
drivers/pci/intel-iommu.c | 2 +-
include/asm-generic/dma-mapping-common.h | 24 +++++++++++-----------
include/linux/dma-mapping.h | 32 +++++++++++++++---------------
37 files changed, 99 insertions(+), 103 deletions(-)

diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index e4a80d8..11a7ea1 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -17,7 +17,7 @@
#include <linux/swiotlb.h>
#include <asm/machvec.h>

-extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;
+extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;

/* swiotlb declarations & definitions: */
extern int swiotlb_late_init_with_default_size (size_t size);
@@ -33,7 +33,7 @@ static inline int use_swiotlb(struct device *dev)
!sba_dma_ops.dma_supported(dev, *dev->dma_mask);
}

-struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
+const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
{
if (use_swiotlb(dev))
return &swiotlb_dma_ops;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 674a837..a4465c6 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2077,7 +2077,7 @@ static struct acpi_driver acpi_sba_ioc_driver = {
},
};

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static int __init
sba_init(void)
@@ -2191,7 +2191,7 @@ sba_page_override(char *str)

__setup("sbapagesize=",sba_page_override);

-struct dma_map_ops sba_dma_ops = {
+const struct dma_map_ops sba_dma_ops = {
.alloc_coherent = sba_alloc_coherent,
.free_coherent = sba_free_coherent,
.map_page = sba_map_page,
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 8d3c79c..71b3af6 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -12,7 +12,7 @@

#define ARCH_HAS_DMA_GET_REQUIRED_MASK

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;
extern struct ia64_machine_vector ia64_mv;
extern void set_iommu_machvec(void);

@@ -24,7 +24,7 @@ extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *daddr, gfp_t gfp)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
void *caddr;

caddr = ops->alloc_coherent(dev, size, daddr, gfp);
@@ -35,7 +35,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *caddr, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
debug_dma_free_coherent(dev, size, caddr, daddr);
ops->free_coherent(dev, size, caddr, daddr);
}
@@ -49,13 +49,13 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->mapping_error(dev, daddr);
}

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->dma_supported(dev, mask);
}

diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299..9ad4279 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -45,7 +45,7 @@ typedef void ia64_mv_kernel_launch_event_t(void);
/* DMA-mapping interface: */
typedef void ia64_mv_dma_init (void);
typedef u64 ia64_mv_dma_get_required_mask (struct device *);
-typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
+typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);

/*
* WARNING: The legacy I/O space is _architected_. Platforms are
@@ -251,7 +251,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
# endif /* CONFIG_IA64_GENERIC */

extern void swiotlb_dma_init(void);
-extern struct dma_map_ops *dma_get_ops(struct device *);
+extern const struct dma_map_ops *dma_get_ops(struct device *);

/*
* Define default versions so we can extend machvec for new platforms without having
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index f2c1600..969398a 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -3,7 +3,7 @@
/* Set this to 1 if there is a HW IOMMU in the system */
int iommu_detected __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
@@ -16,7 +16,7 @@ static int __init dma_init(void)
}
fs_initcall(dma_init);

-struct dma_map_ops *dma_get_ops(struct device *dev)
+const struct dma_map_ops *dma_get_ops(struct device *dev)
{
return dma_ops;
}
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index f6b1ff0..ccacc2f 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -43,7 +43,7 @@ struct device fallback_dev = {
.dma_mask = &fallback_dev.coherent_dma_mask,
};

-extern struct dma_map_ops intel_dma_ops;
+extern const struct dma_map_ops intel_dma_ops;

static int __init pci_iommu_init(void)
{
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 285aae8..61dbab6 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -21,7 +21,7 @@ static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
}

-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = ia64_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
.map_page = swiotlb_map_page,
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 98b6849..8046766 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -464,7 +464,7 @@ int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
return ret;
}

-static struct dma_map_ops sn_dma_ops = {
+static const struct dma_map_ops sn_dma_ops = {
.alloc_coherent = sn_dma_alloc_coherent,
.free_coherent = sn_dma_free_coherent,
.map_page = sn_dma_map_page,
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 6d94d27..50d4cad 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -14,7 +14,7 @@ struct dev_archdata {
struct device_node *of_node;

/* DMA operations on that device */
- struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;

/*
* When an iommu is in use, dma_data is used as a ptr to the base of the
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index e281dae..f025ef0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -67,11 +67,11 @@ static inline unsigned long device_to_mask(struct device *dev)
* Available generic sets of operations
*/
#ifdef CONFIG_PPC64
-extern struct dma_map_ops dma_iommu_ops;
+extern const struct dma_map_ops dma_iommu_ops;
#endif
-extern struct dma_map_ops dma_direct_ops;
+extern const struct dma_map_ops dma_direct_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
/* We don't handle the NULL dev case for ISA for now. We could
* do it via an out of line call but it is not needed for now. The
@@ -84,7 +84,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
return dev->archdata.dma_ops;
}

-static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
+static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
{
dev->archdata.dma_ops = ops;
}
@@ -118,7 +118,7 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return 0;
@@ -132,7 +132,7 @@ static inline int dma_supported(struct device *dev, u64 mask)

static inline int dma_set_mask(struct device *dev, u64 dma_mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return -EIO;
@@ -147,7 +147,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);
void *cpu_addr;

BUG_ON(!dma_ops);
@@ -162,7 +162,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -173,7 +173,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (dma_ops->mapping_error)
return dma_ops->mapping_error(dev, dma_addr);
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index edfc980..1766f59 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -116,6 +116,9 @@ extern void iommu_init_early_iSeries(void);
extern void iommu_init_early_dart(void);
extern void iommu_init_early_pasemi(void);

+/* dma-iommu.c */
+extern int dma_iommu_dma_supported(struct device *dev, u64 mask);
+
#ifdef CONFIG_PCI
extern void pci_iommu_init(void);
extern void pci_direct_iommu_init(void);
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..4030822 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -65,8 +65,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
}

#ifdef CONFIG_PCI
-extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
-extern struct dma_map_ops *get_pci_dma_ops(void);
+extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
+extern const struct dma_map_ops *get_pci_dma_ops(void);
#else /* CONFIG_PCI */
#define set_pci_dma_ops(d)
#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 8979d4c..d2fd0d3 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@

#include <linux/swiotlb.h>

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 37771a5..70f69e7 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -70,7 +70,7 @@ static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
}

/* We support DMA to/from any memory page via the iommu */
-static int dma_iommu_dma_supported(struct device *dev, u64 mask)
+int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
struct iommu_table *tbl = get_iommu_table_base(dev);

@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
return 1;
}

-struct dma_map_ops dma_iommu_ops = {
+const struct dma_map_ops dma_iommu_ops = {
.alloc_coherent = dma_iommu_alloc_coherent,
.free_coherent = dma_iommu_free_coherent,
.map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e96cbbd..bdd6d41 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
* map_page, and unmap_page on highmem, use normal dma_ops
* for everything else.
*/
-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 6215062..ebea59c 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -134,7 +134,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
}
#endif

-struct dma_map_ops dma_direct_ops = {
+const struct dma_map_ops dma_direct_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = dma_direct_map_sg,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index a4c8b38..1b09ad9 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
return 1;
}

-static struct dma_map_ops ibmebus_dma_ops = {
+static const struct dma_map_ops ibmebus_dma_ops = {
.alloc_coherent = ibmebus_alloc_coherent,
.free_coherent = ibmebus_free_coherent,
.map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index e8dfdbd..8583013 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
unsigned int ppc_pci_flags = 0;


-static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
+static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops;

-void set_pci_dma_ops(struct dma_map_ops *dma_ops)
+void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
{
pci_dma_ops = dma_ops;
}

-struct dma_map_ops *get_pci_dma_ops(void)
+const struct dma_map_ops *get_pci_dma_ops(void)
{
return pci_dma_ops;
}
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 77f6421..94bde06 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,14 +601,14 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
vio_cmo_dealloc(viodev, alloc_size);
}

-struct dma_map_ops vio_dma_mapping_ops = {
+static const struct dma_map_ops vio_dma_mapping_ops = {
.alloc_coherent = vio_dma_iommu_alloc_coherent,
.free_coherent = vio_dma_iommu_free_coherent,
.map_sg = vio_dma_iommu_map_sg,
.unmap_sg = vio_dma_iommu_unmap_sg,
+ .dma_supported = dma_iommu_dma_supported,
.map_page = vio_dma_iommu_map_page,
.unmap_page = vio_dma_iommu_unmap_page,
-
};

/**
@@ -855,12 +855,6 @@ static void vio_cmo_bus_remove(struct vio_dev *viodev)
spin_unlock_irqrestore(&vio_cmo.lock, flags);
}

-static void vio_cmo_set_dma_ops(struct vio_dev *viodev)
-{
- vio_dma_mapping_ops.dma_supported = dma_iommu_ops.dma_supported;
- viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
-}
-
/**
* vio_cmo_bus_init - CMO entitlement initialization at bus init time
*
@@ -1032,7 +1026,6 @@ int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
-static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
static void vio_cmo_bus_init(void) {}
static void vio_cmo_sysfs_init(void) { }
#endif /* CONFIG_PPC_SMLPAR */
@@ -1232,7 +1225,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
viodev->dev.archdata.of_node = of_node_get(of_node);

if (firmware_has_feature(FW_FEATURE_CMO))
- vio_cmo_set_dma_ops(viodev);
+ viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
else
viodev->dev.archdata.dma_ops = &dma_iommu_ops;
set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ca5bfdf..1602e09 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)

static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);

-struct dma_map_ops dma_iommu_fixed_ops = {
+const struct dma_map_ops dma_iommu_fixed_ops = {
.alloc_coherent = dma_fixed_alloc_coherent,
.free_coherent = dma_fixed_free_coherent,
.map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index e34b305..20e48ec 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
return mask >= DMA_BIT_MASK(32);
}

-static struct dma_map_ops ps3_sb_dma_ops = {
+static const struct dma_map_ops ps3_sb_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_map_ops ps3_sb_dma_ops = {
.unmap_page = ps3_unmap_page,
};

-static struct dma_map_ops ps3_ioc0_dma_ops = {
+static const struct dma_map_ops ps3_ioc0_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_ioc0_map_sg,
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5a8c308..fb7c253 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -14,10 +14,10 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask);
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#define dma_is_consistent(d, h) (1)

-extern struct dma_map_ops *dma_ops, pci32_dma_ops;
+extern struct const dma_map_ops *dma_ops, pci32_dma_ops;
extern struct bus_type pci_bus_type;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
if (dev->bus == &pci_bus_type)
@@ -31,7 +31,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *cpu_addr;

cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
@@ -42,7 +42,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
ops->free_coherent(dev, size, cpu_addr, dma_handle);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 7690cc2..ece64c9 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4u_dma_ops = {
+static const struct dma_map_ops sun4u_dma_ops = {
.alloc_coherent = dma_4u_alloc_coherent,
.free_coherent = dma_4u_free_coherent,
.map_page = dma_4u_map_page,
@@ -837,7 +837,7 @@ static struct dma_map_ops sun4u_dma_ops = {
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
};

-struct dma_map_ops *dma_ops = &sun4u_dma_ops;
+const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
EXPORT_SYMBOL(dma_ops);

extern int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9f61fd8..bd048db 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -392,7 +392,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
BUG();
}

-struct dma_map_ops sbus_dma_ops = {
+const struct dma_map_ops sbus_dma_ops = {
.alloc_coherent = sbus_alloc_coherent,
.free_coherent = sbus_free_coherent,
.map_page = sbus_map_page,
@@ -403,7 +403,7 @@ struct dma_map_ops sbus_dma_ops = {
.sync_sg_for_device = sbus_sync_sg_for_device,
};

-struct dma_map_ops *dma_ops = &sbus_dma_ops;
+const struct dma_map_ops *dma_ops = &sbus_dma_ops;
EXPORT_SYMBOL(dma_ops);

static int __init sparc_register_ioport(void)
@@ -640,7 +640,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist *
}
}

-struct dma_map_ops pci32_dma_ops = {
+const struct dma_map_ops pci32_dma_ops = {
.alloc_coherent = pci32_alloc_coherent,
.free_coherent = pci32_free_coherent,
.map_page = pci32_map_page,
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 23c33ff..d137fbd 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -525,7 +525,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4v_dma_ops = {
+static const struct dma_map_ops sun4v_dma_ops = {
.alloc_coherent = dma_4v_alloc_coherent,
.free_coherent = dma_4v_free_coherent,
.map_page = dma_4v_map_page,
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index cee34e9..a7c3fa2 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -6,7 +6,7 @@ struct dev_archdata {
void *acpi_handle;
#endif
#ifdef CONFIG_X86_64
-struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;
#endif
#ifdef CONFIG_DMAR
void *iommu; /* hook for IOMMU specific extension */
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 6a25d5d..786b202 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@ extern int iommu_merge;
extern struct device x86_dma_fallback_dev;
extern int panic_on_overflow;

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#ifdef CONFIG_X86_32
return dma_ops;
@@ -44,7 +44,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
/* Make sure we keep the same behaviour */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

@@ -122,7 +122,7 @@ static inline void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *memory;

gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
@@ -149,7 +149,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fd6d21b..8b13915 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -3,7 +3,7 @@

extern void pci_iommu_shutdown(void);
extern void no_iommu_init(void);
-extern struct dma_map_ops nommu_dma_ops;
+extern const struct dma_map_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;
extern int iommu_pass_through;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0285521..c3dc83a 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2069,7 +2069,7 @@ static void prealloc_protection_domains(void)
}
}

-static struct dma_map_ops amd_iommu_dma_ops = {
+static const struct dma_map_ops amd_iommu_dma_ops = {
.alloc_coherent = alloc_coherent,
.free_coherent = free_coherent,
.map_page = map_page,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 971a3be..071558a 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -470,7 +470,7 @@ static void calgary_free_coherent(struct device *dev, size_t size,
free_pages((unsigned long)vaddr, get_order(size));
}

-static struct dma_map_ops calgary_dma_ops = {
+static const struct dma_map_ops calgary_dma_ops = {
.alloc_coherent = calgary_alloc_coherent,
.free_coherent = calgary_free_coherent,
.map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a6e804d..e318f5a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -14,7 +14,7 @@

static int forbid_dac __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

static int iommu_sac_force __read_mostly;
@@ -243,7 +243,7 @@ early_param("iommu", iommu_setup);

int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index a7f1b64..24505d3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -679,7 +679,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
return -1;
}

-static struct dma_map_ops gart_dma_ops = {
+static const struct dma_map_ops gart_dma_ops = {
.map_sg = gart_map_sg,
.unmap_sg = gart_unmap_sg,
.map_page = gart_map_page,
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index a3933d4..c898869 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -94,7 +94,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
flush_write_buffers();
}

-struct dma_map_ops nommu_dma_ops = {
+const struct dma_map_ops nommu_dma_ops = {
.alloc_coherent = dma_generic_alloc_coherent,
.free_coherent = nommu_free_coherent,
.map_sg = nommu_map_sg,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index aaa6b78..4de1881 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -25,7 +25,7 @@ static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
return swiotlb_alloc_coherent(hwdev, size, dma_handle, flags);
}

-static struct dma_map_ops swiotlb_dma_ops = {
+static const struct dma_map_ops swiotlb_dma_ops = {
.mapping_error = swiotlb_dma_mapping_error,
.alloc_coherent = x86_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1840a05..b4ece9f 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2937,7 +2937,7 @@ static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
return !dma_addr;
}

-struct dma_map_ops intel_dma_ops = {
+const struct dma_map_ops intel_dma_ops = {
.alloc_coherent = intel_alloc_coherent,
.free_coherent = intel_free_coherent,
.map_sg = intel_map_sg,
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index e694263..9ffa925 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -11,7 +11,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(ptr, size);
@@ -30,7 +30,7 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -42,7 +42,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
int i, ents;
struct scatterlist *s;

@@ -59,7 +59,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
debug_dma_unmap_sg(dev, sg, nents, dir);
@@ -71,7 +71,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
size_t offset, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(page_address(page) + offset, size);
@@ -85,7 +85,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
size_t size, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -97,7 +97,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_cpu)
@@ -109,7 +109,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_device)
@@ -123,7 +123,7 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_cpu) {
@@ -140,7 +140,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_device) {
@@ -155,7 +155,7 @@ static inline void
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_cpu)
@@ -167,7 +167,7 @@ static inline void
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_device)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 91b7618..fc9996f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -16,50 +16,50 @@ enum dma_data_direction {
};

struct dma_map_ops {
- void* (*alloc_coherent)(struct device *dev, size_t size,
+ void* (* const alloc_coherent)(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
- void (*free_coherent)(struct device *dev, size_t size,
+ void (* const free_coherent)(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);
- dma_addr_t (*map_page)(struct device *dev, struct page *page,
+ dma_addr_t (* const map_page)(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
+ void (* const unmap_page)(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs);
- int (*map_sg)(struct device *dev, struct scatterlist *sg,
+ int (* const map_sg)(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_sg)(struct device *dev,
+ void (* const unmap_sg)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*sync_single_for_cpu)(struct device *dev,
+ void (* const sync_single_for_cpu)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_for_device)(struct device *dev,
+ void (* const sync_single_for_device)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_cpu)(struct device *dev,
+ void (* const sync_single_range_for_cpu)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_device)(struct device *dev,
+ void (* const sync_single_range_for_device)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_sg_for_cpu)(struct device *dev,
+ void (* const sync_sg_for_cpu)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- void (*sync_sg_for_device)(struct device *dev,
+ void (* const sync_sg_for_device)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
- int (*dma_supported)(struct device *dev, u64 mask);
- int (*set_dma_mask)(struct device *dev, u64 mask);
- int is_phys;
+ int (* const mapping_error)(struct device *dev, dma_addr_t dma_addr);
+ int (* const dma_supported)(struct device *dev, u64 mask);
+ int (* const set_dma_mask)(struct device *dev, u64 mask);
+ const int is_phys;
};

#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))

2009-12-05 02:10:15

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Hi Emese,

On Sat, 05 Dec 2009 03:00:25 +0100 Emese Revfy <[email protected]> wrote:
>
> Ok, I made the changes, I also removed the vio_cmo_set_dma_ops function
> because I think it is now unnecessary.

It is necessary because vio_dma_mapping_ops is only defined when
CONFIG_PPC_SMLPAR is set, but that function was called from unconditional
code (and there was a trivial version for when CONFIG_PPC_SMLPAR was not
set) i.e. we only want the dma_ops set if we were built with
CONFIG_PPC_SMLPAR.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (600.00 B)
(No filename) (198.00 B)
Download all attachments

2009-12-05 02:24:00

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Stephen Rothwell wrote:
> Hi Emese,
>
> On Sat, 05 Dec 2009 03:00:25 +0100 Emese Revfy <[email protected]> wrote:
>> Ok, I made the changes, I also removed the vio_cmo_set_dma_ops function
>> because I think it is now unnecessary.
>
> It is necessary because vio_dma_mapping_ops is only defined when
> CONFIG_PPC_SMLPAR is set, but that function was called from unconditional
> code (and there was a trivial version for when CONFIG_PPC_SMLPAR was not
> set) i.e. we only want the dma_ops set if we were built with
> CONFIG_PPC_SMLPAR.

I already took care of these, look at these hunks:

@@ -1033,7 +1026,6 @@ int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
-static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
static void vio_cmo_bus_init(void) {}
static void vio_cmo_sysfs_init(void) { }
#endif /* CONFIG_PPC_SMLPAR */
@@ -1233,7 +1225,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
viodev->dev.archdata.of_node = of_node_get(of_node);

if (firmware_has_feature(FW_FEATURE_CMO))
- vio_cmo_set_dma_ops(viodev);
+ viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
else
viodev->dev.archdata.dma_ops = &dma_iommu_ops;
set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));


If you think it's not enough please let me know.
--
Emese

2009-12-05 02:27:27

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Hi Emese,

On Sat, 05 Dec 2009 03:25:23 +0100 Emese Revfy <[email protected]> wrote:
>
> I already took care of these, look at these hunks:
>
> @@ -1033,7 +1026,6 @@ int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
> void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
> static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
> static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
> -static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
> static void vio_cmo_bus_init(void) {}
> static void vio_cmo_sysfs_init(void) { }
> #endif /* CONFIG_PPC_SMLPAR */
> @@ -1233,7 +1225,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
> viodev->dev.archdata.of_node = of_node_get(of_node);
>
> if (firmware_has_feature(FW_FEATURE_CMO))
> - vio_cmo_set_dma_ops(viodev);
> + viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;

This code is not inside a #ifdef CONFIG_PPC_SMLPAR section, so
vio_dma_mapping_ops may not exist here.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (1.10 kB)
(No filename) (198.00 B)
Download all attachments

2009-12-05 02:49:32

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

Greg KH wrote:
> On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
>> From: Emese Revfy <[email protected]>
>>
>> Constify struct file_operations with some exceptions.
>> Per Dave Miller's suggestion, resend with proper CC list and patch format.
>>
>> Signed-off-by: Emese Revfy <[email protected]>
>> ---
>> drivers/acpi/battery.c | 2 +-
>> drivers/char/pty.c | 16 +++++++++---
>> drivers/char/tty_io.c | 28 ++++-----------------
>> drivers/media/dvb/dvb-core/dvbdev.c | 1 +
>> drivers/net/wireless/b43/debugfs.c | 2 +-
>> drivers/net/wireless/b43legacy/debugfs.c | 2 +-
>> drivers/net/wireless/libertas/debugfs.c | 2 +-
>> drivers/staging/b3dfg/b3dfg.c | 2 +-
>> drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
>> drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
>> drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
>> drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
>> drivers/staging/dream/qdsp5/audio_in.c | 4 +-
>> drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
>> drivers/staging/dream/qdsp5/audio_out.c | 4 +-
>> drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
>> drivers/staging/dream/qdsp5/snd.c | 2 +-
>> drivers/staging/dream/smd/smd_qmi.c | 2 +-
>> drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 +-
>> drivers/staging/panel/panel.c | 4 +-
>> drivers/staging/poch/poch.c | 2 +-
>> drivers/staging/sep/sep_driver.c | 2 +-
>> drivers/staging/vme/devices/vme_user.c | 2 +-
>> fs/fuse/cuse.c | 20 +++++++++------
>> fs/fuse/dev.c | 8 +++---
>> fs/fuse/fuse_i.h | 10 ++++++++
>> include/linux/tty.h | 14 ++++++++++-
>> include/net/tcp.h | 1 +
>> include/net/udp.h | 1 +
>> kernel/trace/trace_events.c | 2 +
>> virt/kvm/kvm_main.c | 3 ++
>> 31 files changed, 89 insertions(+), 63 deletions(-)
>>
>> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
>> index 3f4602b..2e41d36 100644
>> --- a/drivers/acpi/battery.c
>> +++ b/drivers/acpi/battery.c
>> @@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
>> }
>>
>> static struct battery_file {
>> - struct file_operations ops;
>> + const struct file_operations ops;
>> mode_t mode;
>> const char *name;
>> } acpi_battery_file[] = {
>> diff --git a/drivers/char/pty.c b/drivers/char/pty.c
>> index 62f282e..d39c67b 100644
>> --- a/drivers/char/pty.c
>> +++ b/drivers/char/pty.c
>> @@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
>> return ret;
>> }
>>
>> -static struct file_operations ptmx_fops;
>> +static const struct file_operations ptmx_fops = {
>> + .llseek = no_llseek,
>> + .read = tty_read,
>> + .write = tty_write,
>> + .poll = tty_poll,
>> + .unlocked_ioctl = tty_ioctl,
>> + .compat_ioctl = tty_compat_ioctl,
>> + .open = ptmx_open,
>> + .release = tty_release,
>> + .fasync = tty_fasync,
>> +};
>
> You just made these functions all global, for no real good reason. Why
> did you do this?
>
> confused,
>
> greg k-h

I think this is the only way to make ptmx_fops const, provided we want to.
--
Emese

2009-12-05 02:51:10

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Stephen Rothwell wrote:
> Hi Emese,
>
> On Sat, 05 Dec 2009 03:25:23 +0100 Emese Revfy <[email protected]> wrote:
>> I already took care of these, look at these hunks:
>>
>> @@ -1033,7 +1026,6 @@ int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
>> void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
>> static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
>> static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
>> -static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
>> static void vio_cmo_bus_init(void) {}
>> static void vio_cmo_sysfs_init(void) { }
>> #endif /* CONFIG_PPC_SMLPAR */
>> @@ -1233,7 +1225,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
>> viodev->dev.archdata.of_node = of_node_get(of_node);
>>
>> if (firmware_has_feature(FW_FEATURE_CMO))
>> - vio_cmo_set_dma_ops(viodev);
>> + viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
>
> This code is not inside a #ifdef CONFIG_PPC_SMLPAR section, so
> vio_dma_mapping_ops may not exist here.

Thanks, I see it now, here is the updated patch.

From: Emese Revfy <[email protected]>

Constify struct dma_map_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/hp/common/hwsw_iommu.c | 4 +-
arch/ia64/hp/common/sba_iommu.c | 4 +-
arch/ia64/include/asm/dma-mapping.h | 10 ++++----
arch/ia64/include/asm/machvec.h | 4 +-
arch/ia64/kernel/dma-mapping.c | 4 +-
arch/ia64/kernel/pci-dma.c | 2 +-
arch/ia64/kernel/pci-swiotlb.c | 2 +-
arch/ia64/sn/pci/pci_dma.c | 2 +-
arch/powerpc/include/asm/device.h | 2 +-
arch/powerpc/include/asm/dma-mapping.h | 18 ++++++++--------
arch/powerpc/include/asm/iommu.h | 3 ++
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-iommu.c | 4 +-
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 ++--
arch/powerpc/kernel/vio.c | 7 ++---
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 +-
arch/sparc/include/asm/dma-mapping.h | 8 +++---
arch/sparc/kernel/iommu.c | 4 +-
arch/sparc/kernel/ioport.c | 6 ++--
arch/sparc/kernel/pci_sun4v.c | 2 +-
arch/x86/include/asm/device.h | 2 +-
arch/x86/include/asm/dma-mapping.h | 10 ++++----
arch/x86/include/asm/iommu.h | 2 +-
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/pci-calgary_64.c | 2 +-
arch/x86/kernel/pci-dma.c | 4 +-
arch/x86/kernel/pci-gart_64.c | 2 +-
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 2 +-
drivers/pci/intel-iommu.c | 2 +-
include/asm-generic/dma-mapping-common.h | 24 +++++++++++-----------
include/linux/dma-mapping.h | 32 +++++++++++++++---------------
37 files changed, 99 insertions(+), 97 deletions(-)

diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index e4a80d8..11a7ea1 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -17,7 +17,7 @@
#include <linux/swiotlb.h>
#include <asm/machvec.h>

-extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;
+extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;

/* swiotlb declarations & definitions: */
extern int swiotlb_late_init_with_default_size (size_t size);
@@ -33,7 +33,7 @@ static inline int use_swiotlb(struct device *dev)
!sba_dma_ops.dma_supported(dev, *dev->dma_mask);
}

-struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
+const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
{
if (use_swiotlb(dev))
return &swiotlb_dma_ops;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 674a837..a4465c6 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2077,7 +2077,7 @@ static struct acpi_driver acpi_sba_ioc_driver = {
},
};

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static int __init
sba_init(void)
@@ -2191,7 +2191,7 @@ sba_page_override(char *str)

__setup("sbapagesize=",sba_page_override);

-struct dma_map_ops sba_dma_ops = {
+const struct dma_map_ops sba_dma_ops = {
.alloc_coherent = sba_alloc_coherent,
.free_coherent = sba_free_coherent,
.map_page = sba_map_page,
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 8d3c79c..71b3af6 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -12,7 +12,7 @@

#define ARCH_HAS_DMA_GET_REQUIRED_MASK

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;
extern struct ia64_machine_vector ia64_mv;
extern void set_iommu_machvec(void);

@@ -24,7 +24,7 @@ extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *daddr, gfp_t gfp)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
void *caddr;

caddr = ops->alloc_coherent(dev, size, daddr, gfp);
@@ -35,7 +35,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *caddr, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
debug_dma_free_coherent(dev, size, caddr, daddr);
ops->free_coherent(dev, size, caddr, daddr);
}
@@ -49,13 +49,13 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->mapping_error(dev, daddr);
}

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->dma_supported(dev, mask);
}

diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299..9ad4279 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -45,7 +45,7 @@ typedef void ia64_mv_kernel_launch_event_t(void);
/* DMA-mapping interface: */
typedef void ia64_mv_dma_init (void);
typedef u64 ia64_mv_dma_get_required_mask (struct device *);
-typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
+typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);

/*
* WARNING: The legacy I/O space is _architected_. Platforms are
@@ -251,7 +251,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
# endif /* CONFIG_IA64_GENERIC */

extern void swiotlb_dma_init(void);
-extern struct dma_map_ops *dma_get_ops(struct device *);
+extern const struct dma_map_ops *dma_get_ops(struct device *);

/*
* Define default versions so we can extend machvec for new platforms without having
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index f2c1600..969398a 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -3,7 +3,7 @@
/* Set this to 1 if there is a HW IOMMU in the system */
int iommu_detected __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
@@ -16,7 +16,7 @@ static int __init dma_init(void)
}
fs_initcall(dma_init);

-struct dma_map_ops *dma_get_ops(struct device *dev)
+const struct dma_map_ops *dma_get_ops(struct device *dev)
{
return dma_ops;
}
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index f6b1ff0..ccacc2f 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -43,7 +43,7 @@ struct device fallback_dev = {
.dma_mask = &fallback_dev.coherent_dma_mask,
};

-extern struct dma_map_ops intel_dma_ops;
+extern const struct dma_map_ops intel_dma_ops;

static int __init pci_iommu_init(void)
{
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 285aae8..61dbab6 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -21,7 +21,7 @@ static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
}

-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = ia64_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
.map_page = swiotlb_map_page,
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 98b6849..8046766 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -464,7 +464,7 @@ int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
return ret;
}

-static struct dma_map_ops sn_dma_ops = {
+static const struct dma_map_ops sn_dma_ops = {
.alloc_coherent = sn_dma_alloc_coherent,
.free_coherent = sn_dma_free_coherent,
.map_page = sn_dma_map_page,
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 6d94d27..50d4cad 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -14,7 +14,7 @@ struct dev_archdata {
struct device_node *of_node;

/* DMA operations on that device */
- struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;

/*
* When an iommu is in use, dma_data is used as a ptr to the base of the
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index e281dae..f025ef0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -67,11 +67,11 @@ static inline unsigned long device_to_mask(struct device *dev)
* Available generic sets of operations
*/
#ifdef CONFIG_PPC64
-extern struct dma_map_ops dma_iommu_ops;
+extern const struct dma_map_ops dma_iommu_ops;
#endif
-extern struct dma_map_ops dma_direct_ops;
+extern const struct dma_map_ops dma_direct_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
/* We don't handle the NULL dev case for ISA for now. We could
* do it via an out of line call but it is not needed for now. The
@@ -84,7 +84,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
return dev->archdata.dma_ops;
}

-static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
+static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
{
dev->archdata.dma_ops = ops;
}
@@ -118,7 +118,7 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return 0;
@@ -132,7 +132,7 @@ static inline int dma_supported(struct device *dev, u64 mask)

static inline int dma_set_mask(struct device *dev, u64 dma_mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return -EIO;
@@ -147,7 +147,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);
void *cpu_addr;

BUG_ON(!dma_ops);
@@ -162,7 +162,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -173,7 +173,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (dma_ops->mapping_error)
return dma_ops->mapping_error(dev, dma_addr);
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index edfc980..1766f59 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -116,6 +116,9 @@ extern void iommu_init_early_iSeries(void);
extern void iommu_init_early_dart(void);
extern void iommu_init_early_pasemi(void);

+/* dma-iommu.c */
+extern int dma_iommu_dma_supported(struct device *dev, u64 mask);
+
#ifdef CONFIG_PCI
extern void pci_iommu_init(void);
extern void pci_direct_iommu_init(void);
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..4030822 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -65,8 +65,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
}

#ifdef CONFIG_PCI
-extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
-extern struct dma_map_ops *get_pci_dma_ops(void);
+extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
+extern const struct dma_map_ops *get_pci_dma_ops(void);
#else /* CONFIG_PCI */
#define set_pci_dma_ops(d)
#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 8979d4c..d2fd0d3 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@

#include <linux/swiotlb.h>

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 37771a5..70f69e7 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -70,7 +70,7 @@ static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
}

/* We support DMA to/from any memory page via the iommu */
-static int dma_iommu_dma_supported(struct device *dev, u64 mask)
+int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
struct iommu_table *tbl = get_iommu_table_base(dev);

@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
return 1;
}

-struct dma_map_ops dma_iommu_ops = {
+const struct dma_map_ops dma_iommu_ops = {
.alloc_coherent = dma_iommu_alloc_coherent,
.free_coherent = dma_iommu_free_coherent,
.map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e96cbbd..bdd6d41 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
* map_page, and unmap_page on highmem, use normal dma_ops
* for everything else.
*/
-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 6215062..ebea59c 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -134,7 +134,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
}
#endif

-struct dma_map_ops dma_direct_ops = {
+const struct dma_map_ops dma_direct_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = dma_direct_map_sg,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index a4c8b38..1b09ad9 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
return 1;
}

-static struct dma_map_ops ibmebus_dma_ops = {
+static const struct dma_map_ops ibmebus_dma_ops = {
.alloc_coherent = ibmebus_alloc_coherent,
.free_coherent = ibmebus_free_coherent,
.map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index e8dfdbd..8583013 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
unsigned int ppc_pci_flags = 0;


-static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
+static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops;

-void set_pci_dma_ops(struct dma_map_ops *dma_ops)
+void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
{
pci_dma_ops = dma_ops;
}

-struct dma_map_ops *get_pci_dma_ops(void)
+const struct dma_map_ops *get_pci_dma_ops(void)
{
return pci_dma_ops;
}
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 77f6421..ea73cb1 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,14 +601,14 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
vio_cmo_dealloc(viodev, alloc_size);
}

-struct dma_map_ops vio_dma_mapping_ops = {
+static const struct dma_map_ops vio_dma_mapping_ops = {
.alloc_coherent = vio_dma_iommu_alloc_coherent,
.free_coherent = vio_dma_iommu_free_coherent,
.map_sg = vio_dma_iommu_map_sg,
.unmap_sg = vio_dma_iommu_unmap_sg,
+ .dma_supported = dma_iommu_dma_supported,
.map_page = vio_dma_iommu_map_page,
.unmap_page = vio_dma_iommu_unmap_page,
-
};

/**
@@ -857,7 +857,6 @@ static void vio_cmo_bus_remove(struct vio_dev *viodev)

static void vio_cmo_set_dma_ops(struct vio_dev *viodev)
{
- vio_dma_mapping_ops.dma_supported = dma_iommu_ops.dma_supported;
viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
}

@@ -1232,7 +1231,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
viodev->dev.archdata.of_node = of_node_get(of_node);

if (firmware_has_feature(FW_FEATURE_CMO))
- vio_cmo_set_dma_ops(viodev);
+ viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
else
viodev->dev.archdata.dma_ops = &dma_iommu_ops;
set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ca5bfdf..1602e09 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)

static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);

-struct dma_map_ops dma_iommu_fixed_ops = {
+const struct dma_map_ops dma_iommu_fixed_ops = {
.alloc_coherent = dma_fixed_alloc_coherent,
.free_coherent = dma_fixed_free_coherent,
.map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index e34b305..20e48ec 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
return mask >= DMA_BIT_MASK(32);
}

-static struct dma_map_ops ps3_sb_dma_ops = {
+static const struct dma_map_ops ps3_sb_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_map_ops ps3_sb_dma_ops = {
.unmap_page = ps3_unmap_page,
};

-static struct dma_map_ops ps3_ioc0_dma_ops = {
+static const struct dma_map_ops ps3_ioc0_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_ioc0_map_sg,
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5a8c308..fb7c253 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -14,10 +14,10 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask);
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#define dma_is_consistent(d, h) (1)

-extern struct dma_map_ops *dma_ops, pci32_dma_ops;
+extern struct const dma_map_ops *dma_ops, pci32_dma_ops;
extern struct bus_type pci_bus_type;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
if (dev->bus == &pci_bus_type)
@@ -31,7 +31,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *cpu_addr;

cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
@@ -42,7 +42,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
ops->free_coherent(dev, size, cpu_addr, dma_handle);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 7690cc2..ece64c9 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4u_dma_ops = {
+static const struct dma_map_ops sun4u_dma_ops = {
.alloc_coherent = dma_4u_alloc_coherent,
.free_coherent = dma_4u_free_coherent,
.map_page = dma_4u_map_page,
@@ -837,7 +837,7 @@ static struct dma_map_ops sun4u_dma_ops = {
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
};

-struct dma_map_ops *dma_ops = &sun4u_dma_ops;
+const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
EXPORT_SYMBOL(dma_ops);

extern int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9f61fd8..bd048db 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -392,7 +392,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
BUG();
}

-struct dma_map_ops sbus_dma_ops = {
+const struct dma_map_ops sbus_dma_ops = {
.alloc_coherent = sbus_alloc_coherent,
.free_coherent = sbus_free_coherent,
.map_page = sbus_map_page,
@@ -403,7 +403,7 @@ struct dma_map_ops sbus_dma_ops = {
.sync_sg_for_device = sbus_sync_sg_for_device,
};

-struct dma_map_ops *dma_ops = &sbus_dma_ops;
+const struct dma_map_ops *dma_ops = &sbus_dma_ops;
EXPORT_SYMBOL(dma_ops);

static int __init sparc_register_ioport(void)
@@ -640,7 +640,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist *
}
}

-struct dma_map_ops pci32_dma_ops = {
+const struct dma_map_ops pci32_dma_ops = {
.alloc_coherent = pci32_alloc_coherent,
.free_coherent = pci32_free_coherent,
.map_page = pci32_map_page,
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 23c33ff..d137fbd 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -525,7 +525,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4v_dma_ops = {
+static const struct dma_map_ops sun4v_dma_ops = {
.alloc_coherent = dma_4v_alloc_coherent,
.free_coherent = dma_4v_free_coherent,
.map_page = dma_4v_map_page,
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index cee34e9..a7c3fa2 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -6,7 +6,7 @@ struct dev_archdata {
void *acpi_handle;
#endif
#ifdef CONFIG_X86_64
-struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;
#endif
#ifdef CONFIG_DMAR
void *iommu; /* hook for IOMMU specific extension */
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 6a25d5d..786b202 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@ extern int iommu_merge;
extern struct device x86_dma_fallback_dev;
extern int panic_on_overflow;

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#ifdef CONFIG_X86_32
return dma_ops;
@@ -44,7 +44,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
/* Make sure we keep the same behaviour */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

@@ -122,7 +122,7 @@ static inline void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *memory;

gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
@@ -149,7 +149,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fd6d21b..8b13915 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -3,7 +3,7 @@

extern void pci_iommu_shutdown(void);
extern void no_iommu_init(void);
-extern struct dma_map_ops nommu_dma_ops;
+extern const struct dma_map_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;
extern int iommu_pass_through;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0285521..c3dc83a 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2069,7 +2069,7 @@ static void prealloc_protection_domains(void)
}
}

-static struct dma_map_ops amd_iommu_dma_ops = {
+static const struct dma_map_ops amd_iommu_dma_ops = {
.alloc_coherent = alloc_coherent,
.free_coherent = free_coherent,
.map_page = map_page,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 971a3be..071558a 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -470,7 +470,7 @@ static void calgary_free_coherent(struct device *dev, size_t size,
free_pages((unsigned long)vaddr, get_order(size));
}

-static struct dma_map_ops calgary_dma_ops = {
+static const struct dma_map_ops calgary_dma_ops = {
.alloc_coherent = calgary_alloc_coherent,
.free_coherent = calgary_free_coherent,
.map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a6e804d..e318f5a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -14,7 +14,7 @@

static int forbid_dac __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

static int iommu_sac_force __read_mostly;
@@ -243,7 +243,7 @@ early_param("iommu", iommu_setup);

int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index a7f1b64..24505d3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -679,7 +679,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
return -1;
}

-static struct dma_map_ops gart_dma_ops = {
+static const struct dma_map_ops gart_dma_ops = {
.map_sg = gart_map_sg,
.unmap_sg = gart_unmap_sg,
.map_page = gart_map_page,
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index a3933d4..c898869 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -94,7 +94,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
flush_write_buffers();
}

-struct dma_map_ops nommu_dma_ops = {
+const struct dma_map_ops nommu_dma_ops = {
.alloc_coherent = dma_generic_alloc_coherent,
.free_coherent = nommu_free_coherent,
.map_sg = nommu_map_sg,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index aaa6b78..4de1881 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -25,7 +25,7 @@ static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
return swiotlb_alloc_coherent(hwdev, size, dma_handle, flags);
}

-static struct dma_map_ops swiotlb_dma_ops = {
+static const struct dma_map_ops swiotlb_dma_ops = {
.mapping_error = swiotlb_dma_mapping_error,
.alloc_coherent = x86_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1840a05..b4ece9f 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2937,7 +2937,7 @@ static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
return !dma_addr;
}

-struct dma_map_ops intel_dma_ops = {
+const struct dma_map_ops intel_dma_ops = {
.alloc_coherent = intel_alloc_coherent,
.free_coherent = intel_free_coherent,
.map_sg = intel_map_sg,
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index e694263..9ffa925 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -11,7 +11,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(ptr, size);
@@ -30,7 +30,7 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -42,7 +42,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
int i, ents;
struct scatterlist *s;

@@ -59,7 +59,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
debug_dma_unmap_sg(dev, sg, nents, dir);
@@ -71,7 +71,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
size_t offset, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(page_address(page) + offset, size);
@@ -85,7 +85,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
size_t size, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -97,7 +97,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_cpu)
@@ -109,7 +109,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_device)
@@ -123,7 +123,7 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_cpu) {
@@ -140,7 +140,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_device) {
@@ -155,7 +155,7 @@ static inline void
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_cpu)
@@ -167,7 +167,7 @@ static inline void
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_device)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 91b7618..fc9996f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -16,50 +16,50 @@ enum dma_data_direction {
};

struct dma_map_ops {
- void* (*alloc_coherent)(struct device *dev, size_t size,
+ void* (* const alloc_coherent)(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
- void (*free_coherent)(struct device *dev, size_t size,
+ void (* const free_coherent)(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);
- dma_addr_t (*map_page)(struct device *dev, struct page *page,
+ dma_addr_t (* const map_page)(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
+ void (* const unmap_page)(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs);
- int (*map_sg)(struct device *dev, struct scatterlist *sg,
+ int (* const map_sg)(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_sg)(struct device *dev,
+ void (* const unmap_sg)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*sync_single_for_cpu)(struct device *dev,
+ void (* const sync_single_for_cpu)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_for_device)(struct device *dev,
+ void (* const sync_single_for_device)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_cpu)(struct device *dev,
+ void (* const sync_single_range_for_cpu)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_device)(struct device *dev,
+ void (* const sync_single_range_for_device)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_sg_for_cpu)(struct device *dev,
+ void (* const sync_sg_for_cpu)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- void (*sync_sg_for_device)(struct device *dev,
+ void (* const sync_sg_for_device)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
- int (*dma_supported)(struct device *dev, u64 mask);
- int (*set_dma_mask)(struct device *dev, u64 mask);
- int is_phys;
+ int (* const mapping_error)(struct device *dev, dma_addr_t dma_addr);
+ int (* const dma_supported)(struct device *dev, u64 mask);
+ int (* const set_dma_mask)(struct device *dev, u64 mask);
+ const int is_phys;
};

#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))

2009-12-05 03:21:43

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Hi Emese,

On Sat, 05 Dec 2009 03:52:33 +0100 Emese Revfy <[email protected]> wrote:
>
> @@ -1232,7 +1231,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
> viodev->dev.archdata.of_node = of_node_get(of_node);
>
> if (firmware_has_feature(FW_FEATURE_CMO))
> - vio_cmo_set_dma_ops(viodev);
> + viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
> else
> viodev->dev.archdata.dma_ops = &dma_iommu_ops;
> set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));

You forgot to remove this hunk.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (649.00 B)
(No filename) (198.00 B)
Download all attachments

2009-12-05 04:19:21

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On Sat, Dec 05, 2009 at 03:50:23AM +0100, Emese Revfy wrote:
> Greg KH wrote:
> > On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
> >> -static struct file_operations ptmx_fops;
> >> +static const struct file_operations ptmx_fops = {
> >> + .llseek = no_llseek,
> >> + .read = tty_read,
> >> + .write = tty_write,
> >> + .poll = tty_poll,
> >> + .unlocked_ioctl = tty_ioctl,
> >> + .compat_ioctl = tty_compat_ioctl,
> >> + .open = ptmx_open,
> >> + .release = tty_release,
> >> + .fasync = tty_fasync,
> >> +};
> >
> > You just made these functions all global, for no real good reason. Why
> > did you do this?
>
> I think this is the only way to make ptmx_fops const, provided we want to.

Why do we want to?

thanks,

greg k-h

2009-12-05 13:31:13

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 05/31] Constify struct dma_map_ops for 2.6.32 v1

Stephen Rothwell wrote:
> Hi Emese,
>
> On Sat, 05 Dec 2009 03:52:33 +0100 Emese Revfy <[email protected]> wrote:
>> @@ -1232,7 +1231,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
>> viodev->dev.archdata.of_node = of_node_get(of_node);
>>
>> if (firmware_has_feature(FW_FEATURE_CMO))
>> - vio_cmo_set_dma_ops(viodev);
>> + viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
>> else
>> viodev->dev.archdata.dma_ops = &dma_iommu_ops;
>> set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));
>
> You forgot to remove this hunk.

Sorry, it's fixed now.

From: Emese Revfy <[email protected]>

Constify struct dma_map_ops.

Signed-off-by: Emese Revfy <[email protected]>
---
arch/ia64/hp/common/hwsw_iommu.c | 4 +-
arch/ia64/hp/common/sba_iommu.c | 4 +-
arch/ia64/include/asm/dma-mapping.h | 10 ++++----
arch/ia64/include/asm/machvec.h | 4 +-
arch/ia64/kernel/dma-mapping.c | 4 +-
arch/ia64/kernel/pci-dma.c | 2 +-
arch/ia64/kernel/pci-swiotlb.c | 2 +-
arch/ia64/sn/pci/pci_dma.c | 2 +-
arch/powerpc/include/asm/device.h | 2 +-
arch/powerpc/include/asm/dma-mapping.h | 18 ++++++++--------
arch/powerpc/include/asm/iommu.h | 3 ++
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-iommu.c | 4 +-
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 ++--
arch/powerpc/kernel/vio.c | 5 +--
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 +-
arch/sparc/include/asm/dma-mapping.h | 8 +++---
arch/sparc/kernel/iommu.c | 4 +-
arch/sparc/kernel/ioport.c | 6 ++--
arch/sparc/kernel/pci_sun4v.c | 2 +-
arch/x86/include/asm/device.h | 2 +-
arch/x86/include/asm/dma-mapping.h | 10 ++++----
arch/x86/include/asm/iommu.h | 2 +-
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/pci-calgary_64.c | 2 +-
arch/x86/kernel/pci-dma.c | 4 +-
arch/x86/kernel/pci-gart_64.c | 2 +-
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 2 +-
drivers/pci/intel-iommu.c | 2 +-
include/asm-generic/dma-mapping-common.h | 24 +++++++++++-----------
include/linux/dma-mapping.h | 32 +++++++++++++++---------------
37 files changed, 98 insertions(+), 96 deletions(-)

diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index e4a80d8..11a7ea1 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -17,7 +17,7 @@
#include <linux/swiotlb.h>
#include <asm/machvec.h>

-extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;
+extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;

/* swiotlb declarations & definitions: */
extern int swiotlb_late_init_with_default_size (size_t size);
@@ -33,7 +33,7 @@ static inline int use_swiotlb(struct device *dev)
!sba_dma_ops.dma_supported(dev, *dev->dma_mask);
}

-struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
+const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
{
if (use_swiotlb(dev))
return &swiotlb_dma_ops;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 674a837..a4465c6 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2077,7 +2077,7 @@ static struct acpi_driver acpi_sba_ioc_driver = {
},
};

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static int __init
sba_init(void)
@@ -2191,7 +2191,7 @@ sba_page_override(char *str)

__setup("sbapagesize=",sba_page_override);

-struct dma_map_ops sba_dma_ops = {
+const struct dma_map_ops sba_dma_ops = {
.alloc_coherent = sba_alloc_coherent,
.free_coherent = sba_free_coherent,
.map_page = sba_map_page,
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 8d3c79c..71b3af6 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -12,7 +12,7 @@

#define ARCH_HAS_DMA_GET_REQUIRED_MASK

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;
extern struct ia64_machine_vector ia64_mv;
extern void set_iommu_machvec(void);

@@ -24,7 +24,7 @@ extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *daddr, gfp_t gfp)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
void *caddr;

caddr = ops->alloc_coherent(dev, size, daddr, gfp);
@@ -35,7 +35,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *caddr, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
debug_dma_free_coherent(dev, size, caddr, daddr);
ops->free_coherent(dev, size, caddr, daddr);
}
@@ -49,13 +49,13 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->mapping_error(dev, daddr);
}

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ const struct dma_map_ops *ops = platform_dma_get_ops(dev);
return ops->dma_supported(dev, mask);
}

diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299..9ad4279 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -45,7 +45,7 @@ typedef void ia64_mv_kernel_launch_event_t(void);
/* DMA-mapping interface: */
typedef void ia64_mv_dma_init (void);
typedef u64 ia64_mv_dma_get_required_mask (struct device *);
-typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
+typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);

/*
* WARNING: The legacy I/O space is _architected_. Platforms are
@@ -251,7 +251,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
# endif /* CONFIG_IA64_GENERIC */

extern void swiotlb_dma_init(void);
-extern struct dma_map_ops *dma_get_ops(struct device *);
+extern const struct dma_map_ops *dma_get_ops(struct device *);

/*
* Define default versions so we can extend machvec for new platforms without having
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index f2c1600..969398a 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -3,7 +3,7 @@
/* Set this to 1 if there is a HW IOMMU in the system */
int iommu_detected __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
@@ -16,7 +16,7 @@ static int __init dma_init(void)
}
fs_initcall(dma_init);

-struct dma_map_ops *dma_get_ops(struct device *dev)
+const struct dma_map_ops *dma_get_ops(struct device *dev)
{
return dma_ops;
}
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index f6b1ff0..ccacc2f 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -43,7 +43,7 @@ struct device fallback_dev = {
.dma_mask = &fallback_dev.coherent_dma_mask,
};

-extern struct dma_map_ops intel_dma_ops;
+extern const struct dma_map_ops intel_dma_ops;

static int __init pci_iommu_init(void)
{
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 285aae8..61dbab6 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -21,7 +21,7 @@ static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
}

-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = ia64_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
.map_page = swiotlb_map_page,
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 98b6849..8046766 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -464,7 +464,7 @@ int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
return ret;
}

-static struct dma_map_ops sn_dma_ops = {
+static const struct dma_map_ops sn_dma_ops = {
.alloc_coherent = sn_dma_alloc_coherent,
.free_coherent = sn_dma_free_coherent,
.map_page = sn_dma_map_page,
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 6d94d27..50d4cad 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -14,7 +14,7 @@ struct dev_archdata {
struct device_node *of_node;

/* DMA operations on that device */
- struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;

/*
* When an iommu is in use, dma_data is used as a ptr to the base of the
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index e281dae..f025ef0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -67,11 +67,11 @@ static inline unsigned long device_to_mask(struct device *dev)
* Available generic sets of operations
*/
#ifdef CONFIG_PPC64
-extern struct dma_map_ops dma_iommu_ops;
+extern const struct dma_map_ops dma_iommu_ops;
#endif
-extern struct dma_map_ops dma_direct_ops;
+extern const struct dma_map_ops dma_direct_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
/* We don't handle the NULL dev case for ISA for now. We could
* do it via an out of line call but it is not needed for now. The
@@ -84,7 +84,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
return dev->archdata.dma_ops;
}

-static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
+static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
{
dev->archdata.dma_ops = ops;
}
@@ -118,7 +118,7 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return 0;
@@ -132,7 +132,7 @@ static inline int dma_supported(struct device *dev, u64 mask)

static inline int dma_set_mask(struct device *dev, u64 dma_mask)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return -EIO;
@@ -147,7 +147,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);
void *cpu_addr;

BUG_ON(!dma_ops);
@@ -162,7 +162,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -173,7 +173,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ const struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (dma_ops->mapping_error)
return dma_ops->mapping_error(dev, dma_addr);
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index edfc980..1766f59 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -116,6 +116,9 @@ extern void iommu_init_early_iSeries(void);
extern void iommu_init_early_dart(void);
extern void iommu_init_early_pasemi(void);

+/* dma-iommu.c */
+extern int dma_iommu_dma_supported(struct device *dev, u64 mask);
+
#ifdef CONFIG_PCI
extern void pci_iommu_init(void);
extern void pci_direct_iommu_init(void);
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..4030822 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -65,8 +65,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
}

#ifdef CONFIG_PCI
-extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
-extern struct dma_map_ops *get_pci_dma_ops(void);
+extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
+extern const struct dma_map_ops *get_pci_dma_ops(void);
#else /* CONFIG_PCI */
#define set_pci_dma_ops(d)
#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 8979d4c..d2fd0d3 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@

#include <linux/swiotlb.h>

-extern struct dma_map_ops swiotlb_dma_ops;
+extern const struct dma_map_ops swiotlb_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 37771a5..70f69e7 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -70,7 +70,7 @@ static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
}

/* We support DMA to/from any memory page via the iommu */
-static int dma_iommu_dma_supported(struct device *dev, u64 mask)
+int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
struct iommu_table *tbl = get_iommu_table_base(dev);

@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
return 1;
}

-struct dma_map_ops dma_iommu_ops = {
+const struct dma_map_ops dma_iommu_ops = {
.alloc_coherent = dma_iommu_alloc_coherent,
.free_coherent = dma_iommu_free_coherent,
.map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e96cbbd..bdd6d41 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
* map_page, and unmap_page on highmem, use normal dma_ops
* for everything else.
*/
-struct dma_map_ops swiotlb_dma_ops = {
+const struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 6215062..ebea59c 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -134,7 +134,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
}
#endif

-struct dma_map_ops dma_direct_ops = {
+const struct dma_map_ops dma_direct_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = dma_direct_map_sg,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index a4c8b38..1b09ad9 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
return 1;
}

-static struct dma_map_ops ibmebus_dma_ops = {
+static const struct dma_map_ops ibmebus_dma_ops = {
.alloc_coherent = ibmebus_alloc_coherent,
.free_coherent = ibmebus_free_coherent,
.map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index e8dfdbd..8583013 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
unsigned int ppc_pci_flags = 0;


-static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
+static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops;

-void set_pci_dma_ops(struct dma_map_ops *dma_ops)
+void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
{
pci_dma_ops = dma_ops;
}

-struct dma_map_ops *get_pci_dma_ops(void)
+const struct dma_map_ops *get_pci_dma_ops(void)
{
return pci_dma_ops;
}
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 77f6421..2f68442 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,14 +601,14 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
vio_cmo_dealloc(viodev, alloc_size);
}

-struct dma_map_ops vio_dma_mapping_ops = {
+static const struct dma_map_ops vio_dma_mapping_ops = {
.alloc_coherent = vio_dma_iommu_alloc_coherent,
.free_coherent = vio_dma_iommu_free_coherent,
.map_sg = vio_dma_iommu_map_sg,
.unmap_sg = vio_dma_iommu_unmap_sg,
+ .dma_supported = dma_iommu_dma_supported,
.map_page = vio_dma_iommu_map_page,
.unmap_page = vio_dma_iommu_unmap_page,
-
};

/**
@@ -857,7 +857,6 @@ static void vio_cmo_bus_remove(struct vio_dev *viodev)

static void vio_cmo_set_dma_ops(struct vio_dev *viodev)
{
- vio_dma_mapping_ops.dma_supported = dma_iommu_ops.dma_supported;
viodev->dev.archdata.dma_ops = &vio_dma_mapping_ops;
}

diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ca5bfdf..1602e09 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)

static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);

-struct dma_map_ops dma_iommu_fixed_ops = {
+const struct dma_map_ops dma_iommu_fixed_ops = {
.alloc_coherent = dma_fixed_alloc_coherent,
.free_coherent = dma_fixed_free_coherent,
.map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index e34b305..20e48ec 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
return mask >= DMA_BIT_MASK(32);
}

-static struct dma_map_ops ps3_sb_dma_ops = {
+static const struct dma_map_ops ps3_sb_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_map_ops ps3_sb_dma_ops = {
.unmap_page = ps3_unmap_page,
};

-static struct dma_map_ops ps3_ioc0_dma_ops = {
+static const struct dma_map_ops ps3_ioc0_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_ioc0_map_sg,
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5a8c308..fb7c253 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -14,10 +14,10 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask);
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#define dma_is_consistent(d, h) (1)

-extern struct dma_map_ops *dma_ops, pci32_dma_ops;
+extern struct const dma_map_ops *dma_ops, pci32_dma_ops;
extern struct bus_type pci_bus_type;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
if (dev->bus == &pci_bus_type)
@@ -31,7 +31,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *cpu_addr;

cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
@@ -42,7 +42,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
ops->free_coherent(dev, size, cpu_addr, dma_handle);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 7690cc2..ece64c9 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4u_dma_ops = {
+static const struct dma_map_ops sun4u_dma_ops = {
.alloc_coherent = dma_4u_alloc_coherent,
.free_coherent = dma_4u_free_coherent,
.map_page = dma_4u_map_page,
@@ -837,7 +837,7 @@ static struct dma_map_ops sun4u_dma_ops = {
.sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
};

-struct dma_map_ops *dma_ops = &sun4u_dma_ops;
+const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
EXPORT_SYMBOL(dma_ops);

extern int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9f61fd8..bd048db 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -392,7 +392,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
BUG();
}

-struct dma_map_ops sbus_dma_ops = {
+const struct dma_map_ops sbus_dma_ops = {
.alloc_coherent = sbus_alloc_coherent,
.free_coherent = sbus_free_coherent,
.map_page = sbus_map_page,
@@ -403,7 +403,7 @@ struct dma_map_ops sbus_dma_ops = {
.sync_sg_for_device = sbus_sync_sg_for_device,
};

-struct dma_map_ops *dma_ops = &sbus_dma_ops;
+const struct dma_map_ops *dma_ops = &sbus_dma_ops;
EXPORT_SYMBOL(dma_ops);

static int __init sparc_register_ioport(void)
@@ -640,7 +640,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist *
}
}

-struct dma_map_ops pci32_dma_ops = {
+const struct dma_map_ops pci32_dma_ops = {
.alloc_coherent = pci32_alloc_coherent,
.free_coherent = pci32_free_coherent,
.map_page = pci32_map_page,
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 23c33ff..d137fbd 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -525,7 +525,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
spin_unlock_irqrestore(&iommu->lock, flags);
}

-static struct dma_map_ops sun4v_dma_ops = {
+static const struct dma_map_ops sun4v_dma_ops = {
.alloc_coherent = dma_4v_alloc_coherent,
.free_coherent = dma_4v_free_coherent,
.map_page = dma_4v_map_page,
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index cee34e9..a7c3fa2 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -6,7 +6,7 @@ struct dev_archdata {
void *acpi_handle;
#endif
#ifdef CONFIG_X86_64
-struct dma_map_ops *dma_ops;
+ const struct dma_map_ops *dma_ops;
#endif
#ifdef CONFIG_DMAR
void *iommu; /* hook for IOMMU specific extension */
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 6a25d5d..786b202 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@ extern int iommu_merge;
extern struct device x86_dma_fallback_dev;
extern int panic_on_overflow;

-extern struct dma_map_ops *dma_ops;
+extern const struct dma_map_ops *dma_ops;

-static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
#ifdef CONFIG_X86_32
return dma_ops;
@@ -44,7 +44,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
/* Make sure we keep the same behaviour */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

@@ -122,7 +122,7 @@ static inline void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
void *memory;

gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
@@ -149,7 +149,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fd6d21b..8b13915 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -3,7 +3,7 @@

extern void pci_iommu_shutdown(void);
extern void no_iommu_init(void);
-extern struct dma_map_ops nommu_dma_ops;
+extern const struct dma_map_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;
extern int iommu_pass_through;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0285521..c3dc83a 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2069,7 +2069,7 @@ static void prealloc_protection_domains(void)
}
}

-static struct dma_map_ops amd_iommu_dma_ops = {
+static const struct dma_map_ops amd_iommu_dma_ops = {
.alloc_coherent = alloc_coherent,
.free_coherent = free_coherent,
.map_page = map_page,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 971a3be..071558a 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -470,7 +470,7 @@ static void calgary_free_coherent(struct device *dev, size_t size,
free_pages((unsigned long)vaddr, get_order(size));
}

-static struct dma_map_ops calgary_dma_ops = {
+static const struct dma_map_ops calgary_dma_ops = {
.alloc_coherent = calgary_alloc_coherent,
.free_coherent = calgary_free_coherent,
.map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a6e804d..e318f5a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -14,7 +14,7 @@

static int forbid_dac __read_mostly;

-struct dma_map_ops *dma_ops;
+const struct dma_map_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

static int iommu_sac_force __read_mostly;
@@ -243,7 +243,7 @@ early_param("iommu", iommu_setup);

int dma_supported(struct device *dev, u64 mask)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index a7f1b64..24505d3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -679,7 +679,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
return -1;
}

-static struct dma_map_ops gart_dma_ops = {
+static const struct dma_map_ops gart_dma_ops = {
.map_sg = gart_map_sg,
.unmap_sg = gart_unmap_sg,
.map_page = gart_map_page,
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index a3933d4..c898869 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -94,7 +94,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
flush_write_buffers();
}

-struct dma_map_ops nommu_dma_ops = {
+const struct dma_map_ops nommu_dma_ops = {
.alloc_coherent = dma_generic_alloc_coherent,
.free_coherent = nommu_free_coherent,
.map_sg = nommu_map_sg,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index aaa6b78..4de1881 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -25,7 +25,7 @@ static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
return swiotlb_alloc_coherent(hwdev, size, dma_handle, flags);
}

-static struct dma_map_ops swiotlb_dma_ops = {
+static const struct dma_map_ops swiotlb_dma_ops = {
.mapping_error = swiotlb_dma_mapping_error,
.alloc_coherent = x86_swiotlb_alloc_coherent,
.free_coherent = swiotlb_free_coherent,
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1840a05..b4ece9f 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2937,7 +2937,7 @@ static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
return !dma_addr;
}

-struct dma_map_ops intel_dma_ops = {
+const struct dma_map_ops intel_dma_ops = {
.alloc_coherent = intel_alloc_coherent,
.free_coherent = intel_free_coherent,
.map_sg = intel_map_sg,
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index e694263..9ffa925 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -11,7 +11,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(ptr, size);
@@ -30,7 +30,7 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -42,7 +42,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
int i, ents;
struct scatterlist *s;

@@ -59,7 +59,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
debug_dma_unmap_sg(dev, sg, nents, dir);
@@ -71,7 +71,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
size_t offset, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;

kmemcheck_mark_initialized(page_address(page) + offset, size);
@@ -85,7 +85,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
size_t size, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
@@ -97,7 +97,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_cpu)
@@ -109,7 +109,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_for_device)
@@ -123,7 +123,7 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_cpu) {
@@ -140,7 +140,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
size_t size,
enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_single_range_for_device) {
@@ -155,7 +155,7 @@ static inline void
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_cpu)
@@ -167,7 +167,7 @@ static inline void
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{
- struct dma_map_ops *ops = get_dma_ops(dev);
+ const struct dma_map_ops *ops = get_dma_ops(dev);

BUG_ON(!valid_dma_direction(dir));
if (ops->sync_sg_for_device)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 91b7618..fc9996f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -16,50 +16,50 @@ enum dma_data_direction {
};

struct dma_map_ops {
- void* (*alloc_coherent)(struct device *dev, size_t size,
+ void* (* const alloc_coherent)(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
- void (*free_coherent)(struct device *dev, size_t size,
+ void (* const free_coherent)(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);
- dma_addr_t (*map_page)(struct device *dev, struct page *page,
+ dma_addr_t (* const map_page)(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
+ void (* const unmap_page)(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs);
- int (*map_sg)(struct device *dev, struct scatterlist *sg,
+ int (* const map_sg)(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*unmap_sg)(struct device *dev,
+ void (* const unmap_sg)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir,
struct dma_attrs *attrs);
- void (*sync_single_for_cpu)(struct device *dev,
+ void (* const sync_single_for_cpu)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_for_device)(struct device *dev,
+ void (* const sync_single_for_device)(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_cpu)(struct device *dev,
+ void (* const sync_single_range_for_cpu)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_single_range_for_device)(struct device *dev,
+ void (* const sync_single_range_for_device)(struct device *dev,
dma_addr_t dma_handle,
unsigned long offset,
size_t size,
enum dma_data_direction dir);
- void (*sync_sg_for_cpu)(struct device *dev,
+ void (* const sync_sg_for_cpu)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- void (*sync_sg_for_device)(struct device *dev,
+ void (* const sync_sg_for_device)(struct device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction dir);
- int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
- int (*dma_supported)(struct device *dev, u64 mask);
- int (*set_dma_mask)(struct device *dev, u64 mask);
- int is_phys;
+ int (* const mapping_error)(struct device *dev, dma_addr_t dma_addr);
+ int (* const dma_supported)(struct device *dev, u64 mask);
+ int (* const set_dma_mask)(struct device *dev, u64 mask);
+ const int is_phys;
};

#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))

2009-12-05 14:16:09

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On 12/05/2009 01:02 AM, Emese Revfy wrote:
> diff --git a/drivers/char/pty.c b/drivers/char/pty.c
> index 62f282e..d39c67b 100644
> --- a/drivers/char/pty.c
> +++ b/drivers/char/pty.c
> @@ -682,7 +682,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
> return ret;
> }
>
> -static struct file_operations ptmx_fops;
> +static const struct file_operations ptmx_fops = {
> + .llseek = no_llseek,
> + .read = tty_read,
> + .write = tty_write,
> + .poll = tty_poll,
> + .unlocked_ioctl = tty_ioctl,
> + .compat_ioctl = tty_compat_ioctl,
> + .open = ptmx_open,
> + .release = tty_release,
> + .fasync = tty_fasync,
> +};
> +
>
> static void __init unix98_pty_init(void)
> {
> @@ -736,9 +747,6 @@ static void __init unix98_pty_init(void)
> register_sysctl_table(pty_root_table);
>
> /* Now create the /dev/ptmx special device */
> - tty_default_fops(&ptmx_fops);
> - ptmx_fops.open = ptmx_open;
> -

Apart you CCed hundreds of people and mixed thousand things together
into one patch, this makes no sense.

I think the purpose was to not have the fops on multiple places. When
one changes tty_fops, he has to change even ptmx_fops from now on. Not
that I would say the current approach is clean, but this makes it worse IMO.

And as Greg pointed out, you made many functions global for no real income.

2009-12-05 14:27:26

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH 02/31] Constify struct address_space_operations for 2.6.32 v1

On Sat, Dec 05, 2009 at 01:36:56AM +0100, Emese Revfy wrote:
> Matthew Wilcox wrote:
> > On Fri, Dec 04, 2009 at 11:08:09PM +0100, Emese Revfy wrote:
> >> - int (*writepage)(struct page *page, struct writeback_control *wbc);
> >> + int (* const writepage)(struct page *page, struct writeback_control *wbc);
> >
> > Umm. What effect does this have?
> > What changes as a result of this patch?
>
> My idea was that since all variables of this type are const, we might
> as well have the compiler enforce it for the future if you think that
> these fields should not be writable at all.

The compiler does already enforce it. We do it like this:

struct address_space {
const struct address_space_operations *a_ops; /* methods */
}

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."

2009-12-05 21:15:26

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Sat, Dec 05 2009, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
> Per Dave Miller's suggestion, resend with proper CC list and patch format.

For the block parts:

Acked-by: Jens Axboe <[email protected]>

--
Jens Axboe

2009-12-06 00:16:41

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 02/31] Constify struct address_space_operations for 2.6.32 v1

Matthew Wilcox wrote:
> On Sat, Dec 05, 2009 at 01:36:56AM +0100, Emese Revfy wrote:
>> Matthew Wilcox wrote:
>>> On Fri, Dec 04, 2009 at 11:08:09PM +0100, Emese Revfy wrote:
>>>> - int (*writepage)(struct page *page, struct writeback_control *wbc);
>>>> + int (* const writepage)(struct page *page, struct writeback_control *wbc);
>>> Umm. What effect does this have?
>>> What changes as a result of this patch?
>> My idea was that since all variables of this type are const, we might
>> as well have the compiler enforce it for the future if you think that
>> these fields should not be writable at all.
>
> The compiler does already enforce it. We do it like this:
>
> struct address_space {
> const struct address_space_operations *a_ops; /* methods */
> }

This only ensures that the address_space_operations structure cannot be
written through a_ops, but the address_space_operations structure itself
can still be writable. My patch fixes the latter issue.
--
Emese

2009-12-06 00:36:05

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 06/31] Constify struct e1000_mac_operations for net-next-2.6 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_mac_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 3 ++-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 3 ++-
drivers/net/e1000e/hw.h | 1 +
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 3 ++-
drivers/net/igbvf/vf.h | 1 +
8 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index c1a42cf..f388cba 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -207,6 +207,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const, see this function */
struct e1000_mac_operations *func = &mac->ops;
u32 swsm = 0;
u32 swsm2 = 0;
@@ -1692,7 +1693,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
er32(ICRXDMTC);
}

-static struct e1000_mac_operations e82571_mac_ops = {
+static const struct e1000_mac_operations e82571_mac_ops = {
/* .check_mng_mode: mac type dependent */
/* .check_for_link: media type dependent */
.id_led_init = e1000e_id_led_init,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index cebbd90..68e66b2 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -379,7 +379,7 @@ struct e1000_info {
u32 pba;
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index d2a1047..c44d30a 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -202,6 +202,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct e1000_mac_info *mac = &hw->mac;
+ /* cannot be const, see this function */
struct e1000_mac_operations *func = &mac->ops;

/* Set media type */
@@ -1369,7 +1370,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
er32(ICRXDMTC);
}

-static struct e1000_mac_operations es2_mac_ops = {
+static const struct e1000_mac_operations es2_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000e_check_mng_mode_generic,
/* check_for_link dependent on media type */
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index a7d08da..2238d4d 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -791,6 +791,7 @@ struct e1000_nvm_operations {
};

struct e1000_mac_info {
+ /* cannot be const, see drivers/net/e1000e/ich8lan.c:e1000_init_mac_params_ich8lan */
struct e1000_mac_operations ops;

u8 addr[6];
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 7b33be9..614a0d4 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3291,7 +3291,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
}
}

-static struct e1000_mac_operations ich8_mac_ops = {
+static const struct e1000_mac_operations ich8_mac_ops = {
.id_led_init = e1000e_id_led_init,
.check_mng_mode = e1000_check_mng_mode_ich8lan,
.check_for_link = e1000_check_for_copper_link_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index e8e9e91..34b847a 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1585,7 +1585,7 @@ u16 igb_rxpbs_adjust_82580(u32 data)
return ret_val;
}

-static struct e1000_mac_operations e1000_mac_ops_82575 = {
+static const struct e1000_mac_operations e1000_mac_ops_82575 = {
.init_hw = igb_init_hw_82575,
.check_for_link = igb_check_for_link_82575,
.rar_set = igb_rar_set,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index dbaeb5f..854b252 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -324,7 +324,7 @@ struct e1000_nvm_operations {

struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
- struct e1000_mac_operations *mac_ops;
+ const struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};
@@ -332,6 +332,7 @@ struct e1000_info {
extern const struct e1000_info e1000_82575_info;

struct e1000_mac_info {
+ /* cannot be const, see drivers/net/igb/e1000_82575.c:igb_get_invariants_82575 */
struct e1000_mac_operations ops;

u8 addr[6];
diff --git a/drivers/net/igbvf/vf.h b/drivers/net/igbvf/vf.h
index 1e8ce37..4f12659 100644
--- a/drivers/net/igbvf/vf.h
+++ b/drivers/net/igbvf/vf.h
@@ -189,6 +189,7 @@ struct e1000_mac_operations {
};

struct e1000_mac_info {
+ /* cannot be const, see drivers/net/igbvf/vf.c:e1000_init_mac_params_vf */
struct e1000_mac_operations ops;
u8 addr[6];
u8 perm_addr[6];

2009-12-06 00:37:18

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 07/31] Constify struct e1000_nvm_operations for net-next-2.6 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_nvm_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 2 +-
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/hw.h | 16 ++++++++--------
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 3 ++-
7 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index c1a42cf..efc2983 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1766,7 +1766,7 @@ static struct e1000_phy_operations e82_phy_ops_bm = {
.cfg_on_link_up = NULL,
};

-static struct e1000_nvm_operations e82571_nvm_ops = {
+static const struct e1000_nvm_operations e82571_nvm_ops = {
.acquire = e1000_acquire_nvm_82571,
.read = e1000e_read_nvm_eerd,
.release = e1000_release_nvm_82571,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index cebbd90..668112d 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -381,7 +381,7 @@ struct e1000_info {
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

/* hardware capability, feature, and workaround flags */
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index d2a1047..b46291d 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1407,7 +1407,7 @@ static struct e1000_phy_operations es2_phy_ops = {
.cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
};

-static struct e1000_nvm_operations es2_nvm_ops = {
+static const struct e1000_nvm_operations es2_nvm_ops = {
.acquire = e1000_acquire_nvm_80003es2lan,
.read = e1000e_read_nvm_eerd,
.release = e1000_release_nvm_80003es2lan,
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index a7d08da..0a75a9e 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -781,13 +781,13 @@ struct e1000_phy_operations {

/* Function pointers for the NVM. */
struct e1000_nvm_operations {
- s32 (*acquire)(struct e1000_hw *);
- s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
- void (*release)(struct e1000_hw *);
- s32 (*update)(struct e1000_hw *);
- s32 (*valid_led_default)(struct e1000_hw *, u16 *);
- s32 (*validate)(struct e1000_hw *);
- s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
+ s32 (* const acquire)(struct e1000_hw *);
+ s32 (* const read)(struct e1000_hw *, u16, u16, u16 *);
+ void (* const release)(struct e1000_hw *);
+ s32 (* const update)(struct e1000_hw *);
+ s32 (* const valid_led_default)(struct e1000_hw *, u16 *);
+ s32 (* const validate)(struct e1000_hw *);
+ s32 (* const write)(struct e1000_hw *, u16, u16, u16 *);
};

struct e1000_mac_info {
@@ -861,7 +861,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
- struct e1000_nvm_operations ops;
+ const struct e1000_nvm_operations ops;

enum e1000_nvm_type type;
enum e1000_nvm_override override;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 7b33be9..e642cd4 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3323,7 +3323,7 @@ static struct e1000_phy_operations ich8_phy_ops = {
.write_reg = e1000e_write_phy_reg_igp,
};

-static struct e1000_nvm_operations ich8_nvm_ops = {
+static const struct e1000_nvm_operations ich8_nvm_ops = {
.acquire = e1000_acquire_nvm_ich8lan,
.read = e1000_read_nvm_ich8lan,
.release = e1000_release_nvm_ich8lan,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index e8e9e91..b13503e 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1599,7 +1599,7 @@ static struct e1000_phy_operations e1000_phy_ops_82575 = {
.release = igb_release_phy_82575,
};

-static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
+static const struct e1000_nvm_operations e1000_nvm_ops_82575 = {
.acquire = igb_acquire_nvm_82575,
.read = igb_read_nvm_eerd,
.release = igb_release_nvm_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index dbaeb5f..662e1be 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -326,7 +326,7 @@ struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
struct e1000_phy_operations *phy_ops;
- struct e1000_nvm_operations *nvm_ops;
+ const struct e1000_nvm_operations *nvm_ops;
};

extern const struct e1000_info e1000_82575_info;
@@ -412,6 +412,7 @@ struct e1000_phy_info {
};

struct e1000_nvm_info {
+ /* cannot be const, see drivers/net/igb/igb_main.c:igb_probe */
struct e1000_nvm_operations ops;

enum e1000_nvm_type type;

2009-12-06 00:36:22

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 08/31] Constify struct e1000_phy_operations for net-next-2.6 v1

From: Emese Revfy <[email protected]>

Constify struct e1000_phy_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/net/e1000e/82571.c | 6 +++---
drivers/net/e1000e/e1000.h | 2 +-
drivers/net/e1000e/es2lan.c | 2 +-
drivers/net/e1000e/hw.h | 1 +
drivers/net/e1000e/ich8lan.c | 2 +-
drivers/net/igb/e1000_82575.c | 2 +-
drivers/net/igb/e1000_hw.h | 3 ++-
7 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index c1a42cf..d51b8ca 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1712,7 +1712,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations e82_phy_ops_igp = {
+static const struct e1000_phy_operations e82_phy_ops_igp = {
.acquire = e1000_get_hw_semaphore_82571,
.check_polarity = e1000_check_polarity_igp,
.check_reset_block = e1000e_check_reset_block_generic,
@@ -1730,7 +1730,7 @@ static struct e1000_phy_operations e82_phy_ops_igp = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_m88 = {
+static const struct e1000_phy_operations e82_phy_ops_m88 = {
.acquire = e1000_get_hw_semaphore_82571,
.check_polarity = e1000_check_polarity_m88,
.check_reset_block = e1000e_check_reset_block_generic,
@@ -1748,7 +1748,7 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
.cfg_on_link_up = NULL,
};

-static struct e1000_phy_operations e82_phy_ops_bm = {
+static const struct e1000_phy_operations e82_phy_ops_bm = {
.acquire = e1000_get_hw_semaphore_82571,
.check_polarity = e1000_check_polarity_m88,
.check_reset_block = e1000e_check_reset_block_generic,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index cebbd90..e6dada1 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -380,7 +380,7 @@ struct e1000_info {
u32 max_hw_frame_size;
s32 (*get_variants)(struct e1000_adapter *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index d2a1047..ce3049d 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1389,7 +1389,7 @@ static struct e1000_mac_operations es2_mac_ops = {
.setup_led = e1000e_setup_led_generic,
};

-static struct e1000_phy_operations es2_phy_ops = {
+static const struct e1000_phy_operations es2_phy_ops = {
.acquire = e1000_acquire_phy_80003es2lan,
.check_polarity = e1000_check_polarity_m88,
.check_reset_block = e1000e_check_reset_block_generic,
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index a7d08da..8256b2f 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -827,6 +827,7 @@ struct e1000_mac_info {
};

struct e1000_phy_info {
+ /* cannot be const, see drivers/net/e1000e/82571.c:e1000_init_phy_params_82571 */
struct e1000_phy_operations ops;

enum e1000_phy_type type;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 7b33be9..01d56dc 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3309,7 +3309,7 @@ static struct e1000_mac_operations ich8_mac_ops = {
/* id_led_init dependent on mac type */
};

-static struct e1000_phy_operations ich8_phy_ops = {
+static const struct e1000_phy_operations ich8_phy_ops = {
.acquire = e1000_acquire_swflag_ich8lan,
.check_reset_block = e1000_check_reset_block_ich8lan,
.commit = NULL,
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index e8e9e91..0561e55 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -1593,7 +1593,7 @@ static struct e1000_mac_operations e1000_mac_ops_82575 = {
.get_speed_and_duplex = igb_get_speed_and_duplex_copper,
};

-static struct e1000_phy_operations e1000_phy_ops_82575 = {
+static const struct e1000_phy_operations e1000_phy_ops_82575 = {
.acquire = igb_acquire_phy_82575,
.get_cfg_done = igb_get_cfg_done_82575,
.release = igb_release_phy_82575,
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index dbaeb5f..3ae2bd5 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -325,7 +325,7 @@ struct e1000_nvm_operations {
struct e1000_info {
s32 (*get_invariants)(struct e1000_hw *);
struct e1000_mac_operations *mac_ops;
- struct e1000_phy_operations *phy_ops;
+ const struct e1000_phy_operations *phy_ops;
struct e1000_nvm_operations *nvm_ops;
};

@@ -377,6 +377,7 @@ struct e1000_mac_info {
};

struct e1000_phy_info {
+ /* cannot be const, see drivers/net/igb/e1000_82575.c:igb_get_invariants_82575 */
struct e1000_phy_operations ops;

enum e1000_phy_type type;

2009-12-06 01:23:33

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Fri, Dec 04, 2009 at 11:47:15PM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct super_operations.

What the _hell_ is that?

> + struct inode *(* const alloc_inode)(struct super_block *sb);

This is ugly and has all marks of cargo-cult patches. NAKed at least
until you give exceptionally good reasons for doing that.

2009-12-06 01:39:38

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

Al Viro wrote:
> On Fri, Dec 04, 2009 at 11:47:15PM +0100, Emese Revfy wrote:
>> From: Emese Revfy <[email protected]>
>>
>> Constify struct super_operations.
>
> What the _hell_ is that?
>
>> + struct inode *(* const alloc_inode)(struct super_block *sb);
>
> This is ugly and has all marks of cargo-cult patches. NAKed at least
> until you give exceptionally good reasons for doing that.

My idea was that since each instance of super_operations is const,
I figured that there is an implicit policy of not wanting writable
super_operations structures in the kernel. If this is actually the
case then my patch makes the compiler enforce this policy, otherwise
please ignore it.
--
Emese

2009-12-06 01:46:35

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

Greg KH wrote:
> On Sat, Dec 05, 2009 at 03:50:23AM +0100, Emese Revfy wrote:
>> Greg KH wrote:
>>> On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
>>>> -static struct file_operations ptmx_fops;
>>>> +static const struct file_operations ptmx_fops = {
>>>> + .llseek = no_llseek,
>>>> + .read = tty_read,
>>>> + .write = tty_write,
>>>> + .poll = tty_poll,
>>>> + .unlocked_ioctl = tty_ioctl,
>>>> + .compat_ioctl = tty_compat_ioctl,
>>>> + .open = ptmx_open,
>>>> + .release = tty_release,
>>>> + .fasync = tty_fasync,
>>>> +};
>>> You just made these functions all global, for no real good reason. Why
>>> did you do this?
>> I think this is the only way to make ptmx_fops const, provided we want to.
>
> Why do we want to?

Because I saw that checkpatch.pl itself tries to ensure the same I went
through the whole tree looking for non-const file_operations structures
and tried to make them const as best as I could. If you think making
ptmx_fops const is not worth the effort I will remove it from the patch.
--
Emese

2009-12-06 02:36:56

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

Jiri Slaby wrote:
> Apart you CCed hundreds of people

I looked up the maintainers of the patched files from the kernel sources
because I didn't know a better way to let everyone affected know.

> and mixed thousand things together into one patch,

I thought that the best way is to have one patch contain changes for
a single structure type only.
--
Emese






2009-12-06 05:14:47

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

> - struct inode *(*alloc_inode)(struct super_block *sb);
> + struct inode *(* const alloc_inode)(struct super_block *sb);

Good rule is if adding const doesn't move object from one section
to another, it isn't worth it.

I suggest we stick to it or risk another wave of jumbo patches.

2009-12-06 08:58:52

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Sat, 2009-12-05 at 22:15 +0100, Jens Axboe wrote:
> On Sat, Dec 05 2009, Emese Revfy wrote:
> > From: Emese Revfy <[email protected]>
> >
> > Constify struct sysfs_ops.
> > Per Dave Miller's suggestion, resend with proper CC list and patch format.
>
> For the block parts:
>
> Acked-by: Jens Axboe <[email protected]>

For the SLUB parts:

Acked-by: Pekka Enberg <[email protected]>

2009-12-06 09:23:47

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On 12/06/2009 03:38 AM, Emese Revfy wrote:
> Jiri Slaby wrote:
>> Apart you CCed hundreds of people
>
> I looked up the maintainers of the patched files from the kernel sources
> because I didn't know a better way to let everyone affected know.

Well, if you had per subsystem patches, you would Cc only relevant
people per patch.

>> and mixed thousand things together into one patch,
>
> I thought that the best way is to have one patch contain changes for
> a single structure type only.

The problem is that probably nobody will pick them up. Or you would need
to collect Acks from all participants and run with these to Andrew
Morton. Then it's up to him if he wants to merge them. If you split
them, you can ask concrete maintainers for a merge.

--
js

2009-12-06 14:22:23

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

Alexey Dobriyan wrote:
>> - struct inode *(*alloc_inode)(struct super_block *sb);
>> + struct inode *(* const alloc_inode)(struct super_block *sb);
>
> Good rule is if adding const doesn't move object from one section
> to another, it isn't worth it.
>
> I suggest we stick to it or risk another wave of jumbo patches.
>
If all instances of a given ops structure are const and we would like to
preserve this policy for the future as well, then it is very useful
to give future programmers a strong hint about this policy by making
the compiler complain about any violation attempts. Otherwise they may
very well write code that modifies such structures and we will have to
work extra to undo that (or change the policy but in that case it is
good to know why we have to do that).
--
Emese

2009-12-06 17:32:23

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On Sun, Dec 06, 2009 at 02:47:44AM +0100, Emese Revfy wrote:
> Greg KH wrote:
> > On Sat, Dec 05, 2009 at 03:50:23AM +0100, Emese Revfy wrote:
> >> Greg KH wrote:
> >>> On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
> >>>> -static struct file_operations ptmx_fops;
> >>>> +static const struct file_operations ptmx_fops = {
> >>>> + .llseek = no_llseek,
> >>>> + .read = tty_read,
> >>>> + .write = tty_write,
> >>>> + .poll = tty_poll,
> >>>> + .unlocked_ioctl = tty_ioctl,
> >>>> + .compat_ioctl = tty_compat_ioctl,
> >>>> + .open = ptmx_open,
> >>>> + .release = tty_release,
> >>>> + .fasync = tty_fasync,
> >>>> +};
> >>> You just made these functions all global, for no real good reason. Why
> >>> did you do this?
> >> I think this is the only way to make ptmx_fops const, provided we want to.
> >
> > Why do we want to?
>
> Because I saw that checkpatch.pl itself tries to ensure the same I went
> through the whole tree looking for non-const file_operations structures
> and tried to make them const as best as I could. If you think making
> ptmx_fops const is not worth the effort I will remove it from the patch.

Based on the patch, I would think it is not worth it.

thanks,

greg k-h

2009-12-07 00:43:58

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

Greg KH wrote:
> On Sun, Dec 06, 2009 at 02:47:44AM +0100, Emese Revfy wrote:
>> Greg KH wrote:
>>> On Sat, Dec 05, 2009 at 03:50:23AM +0100, Emese Revfy wrote:
>>>> Greg KH wrote:
>>>>> On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
>>>>>> -static struct file_operations ptmx_fops;
>>>>>> +static const struct file_operations ptmx_fops = {
>>>>>> + .llseek = no_llseek,
>>>>>> + .read = tty_read,
>>>>>> + .write = tty_write,
>>>>>> + .poll = tty_poll,
>>>>>> + .unlocked_ioctl = tty_ioctl,
>>>>>> + .compat_ioctl = tty_compat_ioctl,
>>>>>> + .open = ptmx_open,
>>>>>> + .release = tty_release,
>>>>>> + .fasync = tty_fasync,
>>>>>> +};
>>>>> You just made these functions all global, for no real good reason. Why
>>>>> did you do this?
>>>> I think this is the only way to make ptmx_fops const, provided we want to.
>>> Why do we want to?
>> Because I saw that checkpatch.pl itself tries to ensure the same I went
>> through the whole tree looking for non-const file_operations structures
>> and tried to make them const as best as I could. If you think making
>> ptmx_fops const is not worth the effort I will remove it from the patch.
>
> Based on the patch, I would think it is not worth it.
>
> thanks,
>
> greg k-h
>
Ok, I removed the affected hunks.

From: Emese Revfy <[email protected]>

Constify struct file_operations with some exceptions.

Signed-off-by: Emese Revfy <[email protected]>
---
drivers/acpi/battery.c | 2 +-
drivers/char/pty.c | 1 +
drivers/char/tty_io.c | 1 +
drivers/media/dvb/dvb-core/dvbdev.c | 1 +
drivers/net/wireless/b43/debugfs.c | 2 +-
drivers/net/wireless/b43legacy/debugfs.c | 2 +-
drivers/net/wireless/libertas/debugfs.c | 2 +-
drivers/staging/b3dfg/b3dfg.c | 2 +-
drivers/staging/dream/qdsp5/adsp_driver.c | 2 +-
drivers/staging/dream/qdsp5/audio_aac.c | 2 +-
drivers/staging/dream/qdsp5/audio_amrnb.c | 2 +-
drivers/staging/dream/qdsp5/audio_evrc.c | 2 +-
drivers/staging/dream/qdsp5/audio_in.c | 4 ++--
drivers/staging/dream/qdsp5/audio_mp3.c | 2 +-
drivers/staging/dream/qdsp5/audio_out.c | 4 ++--
drivers/staging/dream/qdsp5/audio_qcelp.c | 2 +-
drivers/staging/dream/qdsp5/snd.c | 2 +-
drivers/staging/dream/smd/smd_qmi.c | 2 +-
drivers/staging/dream/smd/smd_rpcrouter_device.c | 4 ++--
drivers/staging/panel/panel.c | 4 ++--
drivers/staging/poch/poch.c | 2 +-
drivers/staging/sep/sep_driver.c | 2 +-
drivers/staging/vme/devices/vme_user.c | 2 +-
fs/char_dev.c | 1 +
fs/fuse/cuse.c | 19 ++++++++++++-------
fs/fuse/dev.c | 8 ++++----
fs/fuse/fuse_i.h | 10 ++++++++++
virt/kvm/kvm_main.c | 3 +++
28 files changed, 57 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3f4602b..2e41d36 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -763,7 +763,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
}

static struct battery_file {
- struct file_operations ops;
+ const struct file_operations ops;
mode_t mode;
const char *name;
} acpi_battery_file[] = {
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 62f282e..96e29e5 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -682,6 +682,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
return ret;
}

+/* cannot be const, see unix98_pty_init */
static struct file_operations ptmx_fops;

static void __init unix98_pty_init(void)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 59499ee..97616a9 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3046,6 +3046,7 @@ struct tty_struct *get_current_tty(void)
}
EXPORT_SYMBOL_GPL(get_current_tty);

+/* cannot be const, see this function */
void tty_default_fops(struct file_operations *fops)
{
*fops = tty_fops;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..9684961 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -191,6 +191,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type)
{
struct dvb_device *dvbdev;
+ /* cannot be const, see this function */
struct file_operations *dvbdevfops;
struct device *clsdev;
int minor;
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 80b19a4..dab3a45 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -43,7 +43,7 @@ static struct dentry *rootdir;
struct b43_debugfs_fops {
ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43_dfs_file in struct b43_dfsentry */
size_t file_struct_offset;
};
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 1f85ac5..c99b4b4 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -44,7 +44,7 @@ static struct dentry *rootdir;
struct b43legacy_debugfs_fops {
ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
- struct file_operations fops;
+ const struct file_operations fops;
/* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
size_t file_struct_offset;
/* Take wl->irq_lock before calling read/write? */
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 893a55c..7f66a50 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -708,7 +708,7 @@ out_unlock:
struct lbs_debugfs_files {
const char *name;
int perm;
- struct file_operations fops;
+ const struct file_operations fops;
};

static const struct lbs_debugfs_files debugfs_files[] = {
diff --git a/drivers/staging/b3dfg/b3dfg.c b/drivers/staging/b3dfg/b3dfg.c
index cda26bb..25f3ec6 100644
--- a/drivers/staging/b3dfg/b3dfg.c
+++ b/drivers/staging/b3dfg/b3dfg.c
@@ -848,7 +848,7 @@ static int b3dfg_mmap(struct file *filp, struct vm_area_struct *vma)
return r;
}

-static struct file_operations b3dfg_fops = {
+static const struct file_operations b3dfg_fops = {
.owner = THIS_MODULE,
.open = b3dfg_open,
.release = b3dfg_release,
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index e55a0db..577b776 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -576,7 +576,7 @@ static struct adsp_device *inode_to_device(struct inode *inode)
static dev_t adsp_devno;
static struct class *adsp_class;

-static struct file_operations adsp_fops = {
+static const struct file_operations adsp_fops = {
.owner = THIS_MODULE,
.open = adsp_open,
.unlocked_ioctl = adsp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index ad2390f..4116ee8 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -1022,7 +1022,7 @@ done:
return rc;
}

-static struct file_operations audio_aac_fops = {
+static const struct file_operations audio_aac_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index cd818a5..870b37b 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -833,7 +833,7 @@ done:
return rc;
}

-static struct file_operations audio_amrnb_fops = {
+static const struct file_operations audio_amrnb_fops = {
.owner = THIS_MODULE,
.open = audamrnb_open,
.release = audamrnb_release,
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index 4b43e18..cedafda 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -805,7 +805,7 @@ dma_fail:
return rc;
}

-static struct file_operations audio_evrc_fops = {
+static const struct file_operations audio_evrc_fops = {
.owner = THIS_MODULE,
.open = audevrc_open,
.release = audevrc_release,
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 3d950a2..9431118 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -913,7 +913,7 @@ static int audpre_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_in_open,
.release = audio_in_release,
@@ -922,7 +922,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_in_ioctl,
};

-static struct file_operations audpre_fops = {
+static const struct file_operations audpre_fops = {
.owner = THIS_MODULE,
.open = audpre_open,
.unlocked_ioctl = audpre_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index b95574f..286c2f4 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -941,7 +941,7 @@ done:
return rc;
}

-static struct file_operations audio_mp3_fops = {
+static const struct file_operations audio_mp3_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index d1adcf6..f8f9833 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -810,7 +810,7 @@ static int audpp_open(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations audio_fops = {
+static const struct file_operations audio_fops = {
.owner = THIS_MODULE,
.open = audio_open,
.release = audio_release,
@@ -819,7 +819,7 @@ static struct file_operations audio_fops = {
.unlocked_ioctl = audio_ioctl,
};

-static struct file_operations audpp_fops = {
+static const struct file_operations audpp_fops = {
.owner = THIS_MODULE,
.open = audpp_open,
.unlocked_ioctl = audpp_ioctl,
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index f0f50e3..f6b9dbc 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -816,7 +816,7 @@ err:
return rc;
}

-static struct file_operations audio_qcelp_fops = {
+static const struct file_operations audio_qcelp_fops = {
.owner = THIS_MODULE,
.open = audqcelp_open,
.release = audqcelp_release,
diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
index 037d7ff..5469ec3 100644
--- a/drivers/staging/dream/qdsp5/snd.c
+++ b/drivers/staging/dream/qdsp5/snd.c
@@ -242,7 +242,7 @@ err:
return rc;
}

-static struct file_operations snd_fops = {
+static const struct file_operations snd_fops = {
.owner = THIS_MODULE,
.open = snd_open,
.release = snd_release,
diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c
index d4e7d88..0ea632a 100644
--- a/drivers/staging/dream/smd/smd_qmi.c
+++ b/drivers/staging/dream/smd/smd_qmi.c
@@ -793,7 +793,7 @@ static int qmi_release(struct inode *ip, struct file *fp)
return 0;
}

-static struct file_operations qmi_fops = {
+static const struct file_operations qmi_fops = {
.owner = THIS_MODULE,
.read = qmi_read,
.write = qmi_write,
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
index cd3910b..ff053d3 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
@@ -214,7 +214,7 @@ static long rpcrouter_ioctl(struct file *filp, unsigned int cmd,
return rc;
}

-static struct file_operations rpcrouter_server_fops = {
+static const struct file_operations rpcrouter_server_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
@@ -224,7 +224,7 @@ static struct file_operations rpcrouter_server_fops = {
.unlocked_ioctl = rpcrouter_ioctl,
};

-static struct file_operations rpcrouter_router_fops = {
+static const struct file_operations rpcrouter_router_fops = {
.owner = THIS_MODULE,
.open = rpcrouter_open,
.release = rpcrouter_release,
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 4ce399b..225f9bc 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -1305,7 +1305,7 @@ static int lcd_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations lcd_fops = {
+static const struct file_operations lcd_fops = {
.write = lcd_write,
.open = lcd_open,
.release = lcd_release,
@@ -1565,7 +1565,7 @@ static int keypad_release(struct inode *inode, struct file *file)
return 0;
}

-static struct file_operations keypad_fops = {
+static const struct file_operations keypad_fops = {
.read = keypad_read, /* read */
.open = keypad_open, /* open */
.release = keypad_release, /* close */
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index 2eb8e3d..57616a7 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1057,7 +1057,7 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
return 0;
}

-static struct file_operations poch_fops = {
+static const struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index f890a16..509ece8 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -2603,7 +2603,7 @@ static struct pci_driver sep_pci_driver = {
static dev_t sep_devno;

/* the files operations structure of the driver */
-static struct file_operations sep_file_operations = {
+static const struct file_operations sep_file_operations = {
.owner = THIS_MODULE,
.ioctl = sep_ioctl,
.poll = sep_poll,
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 7891288..8e31300 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -136,7 +136,7 @@ static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
static int __init vme_user_probe(struct device *, int, int);
static int __exit vme_user_remove(struct device *, int, int);

-static struct file_operations vme_user_fops = {
+static const struct file_operations vme_user_fops = {
.open = vme_user_open,
.release = vme_user_release,
.read = vme_user_read,
diff --git a/fs/char_dev.c b/fs/char_dev.c
index d6db933..7b47e79 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -547,6 +547,7 @@ struct cdev *cdev_alloc(void)
* Initializes @cdev, remembering @fops, making it ready to add to the
* system with cdev_add().
*/
+
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index de792dc..2115e7f 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -528,7 +528,18 @@ static int cuse_channel_release(struct inode *inode, struct file *file)
return rc;
}

-static struct file_operations cuse_channel_fops; /* initialized during init */
+static const struct file_operations cuse_channel_fops = { /* initialized during init */
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = do_sync_read,
+ .aio_read = fuse_dev_read,
+ .write = do_sync_write,
+ .aio_write = fuse_dev_write,
+ .poll = fuse_dev_poll,
+ .open = cuse_channel_open,
+ .release = cuse_channel_release,
+ .fasync = fuse_dev_fasync,
+};


/**************************************************************************
@@ -575,12 +586,6 @@ static int __init cuse_init(void)
for (i = 0; i < CUSE_CONNTBL_LEN; i++)
INIT_LIST_HEAD(&cuse_conntbl[i]);

- /* inherit and extend fuse_dev_operations */
- cuse_channel_fops = fuse_dev_operations;
- cuse_channel_fops.owner = THIS_MODULE;
- cuse_channel_fops.open = cuse_channel_open;
- cuse_channel_fops.release = cuse_channel_release;
-
cuse_class = class_create(THIS_MODULE, "cuse");
if (IS_ERR(cuse_class))
return PTR_ERR(cuse_class);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 51d9e33..03c8f95 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -745,7 +745,7 @@ __releases(&fc->lock)
* request_end(). Otherwise add it to the processing list, and set
* the 'sent' flag.
*/
-static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -987,7 +987,7 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out,
* it from the list and copy the rest of the buffer to the request.
* The request is finished by calling request_end()
*/
-static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
@@ -1084,7 +1084,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
return err;
}

-static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
+unsigned fuse_dev_poll(struct file *file, poll_table *wait)
{
unsigned mask = POLLOUT | POLLWRNORM;
struct fuse_conn *fc = fuse_get_conn(file);
@@ -1210,7 +1210,7 @@ int fuse_dev_release(struct inode *inode, struct file *file)
}
EXPORT_SYMBOL_GPL(fuse_dev_release);

-static int fuse_dev_fasync(int fd, struct file *file, int on)
+int fuse_dev_fasync(int fd, struct file *file, int on)
{
struct fuse_conn *fc = fuse_get_conn(file);
if (!fc)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 01cc462..b11fe78 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -521,6 +521,16 @@ extern const struct file_operations fuse_dev_operations;

extern const struct dentry_operations fuse_dentry_operations;

+extern ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos);
+
+extern unsigned fuse_dev_poll(struct file *file, poll_table *wait);
+
+extern int fuse_dev_fasync(int fd, struct file *file, int on);
+
/**
* Inode to nodeid comparison.
*/
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7495ce3..3ddb0c8 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1745,6 +1745,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
return 0;
}

+/* cannot be const, see kvm_init */
static struct file_operations kvm_vcpu_fops = {
.release = kvm_vcpu_release,
.unlocked_ioctl = kvm_vcpu_ioctl,
@@ -2341,6 +2342,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}

+/* cannot be const, see kvm_init */
static struct file_operations kvm_vm_fops = {
.release = kvm_vm_release,
.unlocked_ioctl = kvm_vm_ioctl,
@@ -2428,6 +2430,7 @@ out:
return r;
}

+/* cannot be const, see kvm_init */
static struct file_operations kvm_chardev_ops = {
.unlocked_ioctl = kvm_dev_ioctl,
.compat_ioctl = kvm_dev_ioctl,

2009-12-07 09:58:22

by Hans J. Koch

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Sat, Dec 05, 2009 at 01:03:07AM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
> Per Dave Miller's suggestion, resend with proper CC list and patch format.
>
> Signed-off-by: Emese Revfy <[email protected]>

For the Userspace I/O part:
Acked-by: Hans J. Koch <[email protected]>

> ---

[...]

> drivers/uio/uio.c | 4 ++--

[...]

> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index e941367..4de382a 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -129,7 +129,7 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
> return entry->show(mem, buf);
> }
>
> -static struct sysfs_ops map_sysfs_ops = {
> +static const struct sysfs_ops map_sysfs_ops = {
> .show = map_type_show,
> };
>
> @@ -217,7 +217,7 @@ static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr,
> return entry->show(port, buf);
> }
>
> -static struct sysfs_ops portio_sysfs_ops = {
> +static const struct sysfs_ops portio_sysfs_ops = {
> .show = portio_type_show,
> };

2009-12-07 14:12:40

by Chris Mason

[permalink] [raw]
Subject: Re: [PATCH 09/31] Constify struct extent_io_ops for 2.6.32 v1

On Fri, Dec 04, 2009 at 11:21:00PM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct extent_io_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> fs/btrfs/disk-io.c | 4 ++--
> fs/btrfs/extent_io.h | 30 +++++++++++++++---------------
> fs/btrfs/inode.c | 4 ++--
> 3 files changed, 19 insertions(+), 19 deletions(-)
>

Thanks, I'll pick this up in the btrfs tree unless Linus has already
grabbed it.

-chris

2009-12-07 15:15:03

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On Mon, Dec 07, 2009 at 01:45:02AM +0100, Emese Revfy wrote:
> Greg KH wrote:
> > On Sun, Dec 06, 2009 at 02:47:44AM +0100, Emese Revfy wrote:
> >> Greg KH wrote:
> >>> On Sat, Dec 05, 2009 at 03:50:23AM +0100, Emese Revfy wrote:
> >>>> Greg KH wrote:
> >>>>> On Sat, Dec 05, 2009 at 01:02:59AM +0100, Emese Revfy wrote:
> >>>>>> -static struct file_operations ptmx_fops;
> >>>>>> +static const struct file_operations ptmx_fops = {
> >>>>>> + .llseek = no_llseek,
> >>>>>> + .read = tty_read,
> >>>>>> + .write = tty_write,
> >>>>>> + .poll = tty_poll,
> >>>>>> + .unlocked_ioctl = tty_ioctl,
> >>>>>> + .compat_ioctl = tty_compat_ioctl,
> >>>>>> + .open = ptmx_open,
> >>>>>> + .release = tty_release,
> >>>>>> + .fasync = tty_fasync,
> >>>>>> +};
> >>>>> You just made these functions all global, for no real good reason. Why
> >>>>> did you do this?
> >>>> I think this is the only way to make ptmx_fops const, provided we want to.
> >>> Why do we want to?
> >> Because I saw that checkpatch.pl itself tries to ensure the same I went
> >> through the whole tree looking for non-const file_operations structures
> >> and tried to make them const as best as I could. If you think making
> >> ptmx_fops const is not worth the effort I will remove it from the patch.
> >
> > Based on the patch, I would think it is not worth it.
> >
> > thanks,
> >
> > greg k-h
> >
> Ok, I removed the affected hunks.
>
> From: Emese Revfy <[email protected]>
>
> Constify struct file_operations with some exceptions.

Now please break this patch (and your others) out into "one subsystem at
a time" type thing so it will have a chance at being applied.

thanks,

greg k-h

2009-12-07 17:33:54

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

>> From: Emese Revfy <[email protected]>
>>
>> Constify struct file_operations with some exceptions.
>
> Now please break this patch (and your others) out into "one subsystem at
> a time" type thing so it will have a chance at being applied.

Shall i split them up per subsystem and structure type or
only per subsystem (that is, include all affected structures
in the given subsystem)?
--
Emese

2009-12-07 17:46:18

by Matt Domsch

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Fri, Dec 04, 2009 at 11:49:06PM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> drivers/firmware/edd.c | 2 +-
> drivers/firmware/efivars.c | 2 +-

Acked-by: Matt Domsch <[email protected]>


--
Matt Domsch
Technology Strategist, Dell Office of the CTO
linux.dell.com & http://www.dell.com/linux

2009-12-07 18:06:48

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 11/31] Constify struct file_operations for 2.6.32 v1

On Mon, Dec 07, 2009 at 06:35:07PM +0100, Emese Revfy wrote:
> >> From: Emese Revfy <[email protected]>
> >>
> >> Constify struct file_operations with some exceptions.
> >
> > Now please break this patch (and your others) out into "one subsystem at
> > a time" type thing so it will have a chance at being applied.
>
> Shall i split them up per subsystem and structure type or
> only per subsystem (that is, include all affected structures
> in the given subsystem)?

Both.

thanks,

greg k-h

2009-12-07 18:30:54

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On 12/6/09, Emese Revfy <[email protected]> wrote:
> Alexey Dobriyan wrote:
>>> - struct inode *(*alloc_inode)(struct super_block *sb);
>>> + struct inode *(* const alloc_inode)(struct super_block *sb);
>>
>> Good rule is if adding const doesn't move object from one section
>> to another, it isn't worth it.
>>
>> I suggest we stick to it or risk another wave of jumbo patches.
>>
> If all instances of a given ops structure are const and we would like to
> preserve this policy for the future as well, then it is very useful
> to give future programmers a strong hint about this policy by making
> the compiler complain about any violation attempts. Otherwise they may
> very well write code that modifies such structures and we will have to
> work extra to undo that (or change the policy but in that case it is
> good to know why we have to do that).

You may want to look what filesystems do with superblock operations.
And after super operations were made const writes to it will be caught
with readonly .rodata config option.

You're going too far with these modifiers.

Nothing will be caught.

2009-12-07 18:41:19

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH 21/31] Constify struct mtrr_ops for 2.6.32 v1

On 12/04/2009 02:38 PM, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct mtrr_ops.
>

Acked-by: H. Peter Anvin <[email protected]>

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

2009-12-07 19:14:54

by David Teigland

[permalink] [raw]
Subject: Re: [PATCH 29/31] Constify struct sysfs_ops for 2.6.32 v1

On Fri, Dec 04, 2009 at 11:49:06PM +0100, Emese Revfy wrote:
> From: Emese Revfy <[email protected]>
>
> Constify struct sysfs_ops.
>
> Signed-off-by: Emese Revfy <[email protected]>
> ---
> fs/dlm/lockspace.c | 2 +-

Acked-by: David Teigland <[email protected]>

2009-12-07 23:25:26

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 09/31] Constify struct extent_io_ops for 2.6.32 v1

Chris Mason wrote:
> On Fri, Dec 04, 2009 at 11:21:00PM +0100, Emese Revfy wrote:
>> From: Emese Revfy <[email protected]>
>>
>> Constify struct extent_io_ops.
>>
>> Signed-off-by: Emese Revfy <[email protected]>
>> ---
>> fs/btrfs/disk-io.c | 4 ++--
>> fs/btrfs/extent_io.h | 30 +++++++++++++++---------------
>> fs/btrfs/inode.c | 4 ++--
>> 3 files changed, 19 insertions(+), 19 deletions(-)
>>
>
> Thanks, I'll pick this up in the btrfs tree unless Linus has already
> grabbed it.
>
> -chris

He hasn't responded so far, so feel free to pick it up yourself.
Thanks, Emese

2009-12-08 00:04:37

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

Alexey Dobriyan wrote:
> On 12/6/09, Emese Revfy <[email protected]> wrote:
>> Alexey Dobriyan wrote:
>>>> - struct inode *(*alloc_inode)(struct super_block *sb);
>>>> + struct inode *(* const alloc_inode)(struct super_block *sb);
>>> Good rule is if adding const doesn't move object from one section
>>> to another, it isn't worth it.
>>>
>>> I suggest we stick to it or risk another wave of jumbo patches.
>>>
>> If all instances of a given ops structure are const and we would like to
>> preserve this policy for the future as well, then it is very useful
>> to give future programmers a strong hint about this policy by making
>> the compiler complain about any violation attempts. Otherwise they may
>> very well write code that modifies such structures and we will have to
>> work extra to undo that (or change the policy but in that case it is
>> good to know why we have to do that).
>
> You may want to look what filesystems do with superblock operations.
> And after super operations were made const writes to it will be caught
> with readonly .rodata config option.
>
> You're going too far with these modifiers.
>
> Nothing will be caught.

DEBUG_RODATA catches the unwanted write attempt at runtime whereas
my patch will catch it at compile time. I think it's better to detect
an error as early as possible.
--
Emese

2009-12-08 01:51:44

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Tue, Dec 08, 2009 at 01:06:38AM +0100, Emese Revfy wrote:

> DEBUG_RODATA catches the unwanted write attempt at runtime whereas
> my patch will catch it at compile time. I think it's better to detect
> an error as early as possible.

Not when the price is readability. Moreover, you *still* are not
covering the real policy - these suckers should be statically allocated,
not just never modified.

2009-12-09 00:22:40

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

Al Viro wrote:
> On Tue, Dec 08, 2009 at 01:06:38AM +0100, Emese Revfy wrote:
>
>> DEBUG_RODATA catches the unwanted write attempt at runtime whereas
>> my patch will catch it at compile time. I think it's better to detect
>> an error as early as possible.
>
> Not when the price is readability.

If constifying the function pointer fields reduces readability,
what would you say for turning then into typedefs, something like this:

typedef int (* super_ops_statfs) (struct dentry *, struct kstatfs *);
struct super_operations {
...
const super_ops_statfs statfs;
...
};

> Moreover, you *still* are not
> covering the real policy - these suckers should be statically allocated,
> not just never modified.

If the super ops are allocated on the stack then they will be overwritten
during later syscalls and will eventually crash the system on a future
dereference, that is, this kind of problem manifests during development.

If the super ops are allocated by kmalloc/etc, then they will have to be
explicitly initialised by writing to specific fields, my patch would prevent
that.

So in the end the programmer is forced to allocate and initialise super ops
statically.
---
Emese

2009-12-09 00:47:30

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Wed, Dec 09, 2009 at 01:24:34AM +0100, Emese Revfy wrote:

> If constifying the function pointer fields reduces readability,
> what would you say for turning then into typedefs, something like this:
>
> typedef int (* super_ops_statfs) (struct dentry *, struct kstatfs *);
> struct super_operations {
> ...
> const super_ops_statfs statfs;
> ...
> };

Even worse, since one has to go back to typedef to figure out WTF is
going on.

> > Moreover, you *still* are not
> > covering the real policy - these suckers should be statically allocated,
> > not just never modified.
>
> If the super ops are allocated on the stack then they will be overwritten
> during later syscalls and will eventually crash the system on a future
> dereference, that is, this kind of problem manifests during development.
>
> If the super ops are allocated by kmalloc/etc, then they will have to be
> explicitly initialised by writing to specific fields, my patch would prevent
> that.
>
> So in the end the programmer is forced to allocate and initialise super ops
> statically.

... unless they go ahead and use memcpy(), etc.

What you really want is
* no conversions to any other pointer types for pointers to it
and to any aggregate types containing it
* no conversions from any other pointer types for the same set of
types
* all objects of that type have static storage duration
* no lvalues of that type are modifiable

Which is not a job for C compiler. Yes, (4) means that memcpy() et.al.
give undefined behaviour. And you get fsck-all satisfaction from knowing
that, since C compiler is not going to warn you about it. sparse might,
if we teach it to do so. Preferably - with minimal intrusiveness of
syntax being used.

2009-12-09 01:32:21

by Ralf Baechle

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Sun, Dec 06, 2009 at 08:14:46AM +0300, Alexey Dobriyan wrote:

> Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1
> Content-Type: text/plain; charset=ISO-8859-1
>
> > - struct inode *(*alloc_inode)(struct super_block *sb);
> > + struct inode *(* const alloc_inode)(struct super_block *sb);
>
> Good rule is if adding const doesn't move object from one section
> to another, it isn't worth it.

On MIPS I've changed a few pointer arguments that frequently were abused
by platform-specific code to const just to make sure such code blows up
at compile time and not later in my mail folder at review time.

Ralf

2009-12-09 01:45:57

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Wed, Dec 09, 2009 at 01:31:10AM +0000, Ralf Baechle wrote:
> On Sun, Dec 06, 2009 at 08:14:46AM +0300, Alexey Dobriyan wrote:
>
> > Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > > - struct inode *(*alloc_inode)(struct super_block *sb);
> > > + struct inode *(* const alloc_inode)(struct super_block *sb);
> >
> > Good rule is if adding const doesn't move object from one section
> > to another, it isn't worth it.
>
> On MIPS I've changed a few pointer arguments that frequently were abused
> by platform-specific code to const just to make sure such code blows up
> at compile time and not later in my mail folder at review time.

Seriously, folks, that looks like a fun sparse project: new type attribute
that makes pointer conversions complain (inherited by aggregates containing
one of such things) + one that restricts storage classes (again, inherited
the same way). Another fun attribute: "no embedding into other objects".
__force casts would suppress complaints in places where e.g. noconvert
objects get allocated.

2009-12-09 08:29:01

by Olivier Galibert

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

On Wed, Dec 09, 2009 at 12:47:34AM +0000, Al Viro wrote:
> What you really want is
> * no conversions to any other pointer types for pointers to it
> and to any aggregate types containing it
> * no conversions from any other pointer types for the same set of
> types
> * all objects of that type have static storage duration
> * no lvalues of that type are modifiable

What about the ->owner field?

OG.

2009-12-10 18:22:22

by Emese Revfy

[permalink] [raw]
Subject: Re: [PATCH 28/31] Constify struct super_operations for 2.6.32 v1

Al Viro wrote:
> On Wed, Dec 09, 2009 at 01:24:34AM +0100, Emese Revfy wrote:
>
>> If constifying the function pointer fields reduces readability,
>> what would you say for turning then into typedefs, something like this:
>>
>> typedef int (* super_ops_statfs) (struct dentry *, struct kstatfs *);
>> struct super_operations {
>> ...
>> const super_ops_statfs statfs;
>> ...
>> };
>
> Even worse, since one has to go back to typedef to figure out WTF is
> going on.
>
>>> Moreover, you *still* are not
>>> covering the real policy - these suckers should be statically allocated,
>>> not just never modified.
>> If the super ops are allocated on the stack then they will be overwritten
>> during later syscalls and will eventually crash the system on a future
>> dereference, that is, this kind of problem manifests during development.
>>
>> If the super ops are allocated by kmalloc/etc, then they will have to be
>> explicitly initialised by writing to specific fields, my patch would prevent
>> that.
>>
>> So in the end the programmer is forced to allocate and initialise super ops
>> statically.
>
> ... unless they go ahead and use memcpy(), etc.
>
> What you really want is
> * no conversions to any other pointer types for pointers to it
> and to any aggregate types containing it
> * no conversions from any other pointer types for the same set of
> types
> * all objects of that type have static storage duration
> * no lvalues of that type are modifiable
>
> Which is not a job for C compiler. Yes, (4) means that memcpy() et.al.
> give undefined behaviour. And you get fsck-all satisfaction from knowing
> that, since C compiler is not going to warn you about it. sparse might,
> if we teach it to do so. Preferably - with minimal intrusiveness of
> syntax being used.

I think, all these instruments (constification, sparse, etc.) are not
for preventing a programmer from circumventing the policy (that's impossible),
but to make it easy for the reviewer to notice it when he does so.
My patch achieves this in a very simple way for the currently uncovered case of dynamically
allocated ops structures.
--
Emese