public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi: const-ify functions
@ 2010-12-08 18:25 Hanno Böck
  2010-12-08 19:17 ` Alexey Dobriyan
  0 siblings, 1 reply; 2+ messages in thread
From: Hanno Böck @ 2010-12-08 18:25 UTC (permalink / raw)
  To: lenb; +Cc: linux-kernel, linux-acpi

[-- Attachment #1: Type: Text/Plain, Size: 5496 bytes --]

Will const a couple of functions and variables. This is extracted
from grsecurity (with only a slight modification to limit a line
to 80 chars).

Patch is against linux-acpi-2.6 git.

Similar patches have been sent in the past but not applied,
supposedly because they weren't sent to subsystem maintainers.
(I may continue to send similar extracts to other subsystems)

---
Signed-off-by: Hanno Boeck <hanno@hboeck.de>
diff -Naurp linux-acpi-1//drivers/acpi/battery.c linux-acpi-2/drivers/acpi/battery.c
--- linux-acpi-1//drivers/acpi/battery.c	2010-12-08 18:42:26.187000005 +0100
+++ linux-acpi-2/drivers/acpi/battery.c	2010-12-08 18:42:53.595000204 +0100
@@ -851,7 +851,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 -Naurp linux-acpi-1//drivers/acpi/dock.c linux-acpi-2/drivers/acpi/dock.c
--- linux-acpi-1//drivers/acpi/dock.c	2010-12-08 18:42:26.147999998 +0100
+++ linux-acpi-2/drivers/acpi/dock.c	2010-12-08 18:42:53.608999978 +0100
@@ -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;
 };
 
@@ -589,7 +589,8 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifi
  * 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 -Naurp linux-acpi-1//drivers/acpi/sleep.c linux-acpi-2/drivers/acpi/sleep.c
--- linux-acpi-1//drivers/acpi/sleep.c	2010-12-08 18:42:27.559999989 +0100
+++ linux-acpi-2/drivers/acpi/sleep.c	2010-12-08 18:42:53.615000007 +0100
@@ -319,7 +319,7 @@ static int acpi_suspend_state_valid(susp
 	}
 }
 
-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,
@@ -347,7 +347,7 @@ static int acpi_suspend_begin_old(suspen
  * 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_pre_suspend,
@@ -498,7 +498,7 @@ static void acpi_pm_thaw(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_pm_prepare,
@@ -541,7 +541,7 @@ static int acpi_hibernation_begin_old(vo
  * 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_pm_pre_suspend,
diff -Naurp linux-acpi-1//drivers/acpi/video.c linux-acpi-2/drivers/acpi/video.c
--- linux-acpi-1//drivers/acpi/video.c	2010-12-08 18:42:27.627999905 +0100
+++ linux-acpi-2/drivers/acpi/video.c	2010-12-08 18:42:53.621000001 +0100
@@ -260,7 +260,7 @@ static int acpi_video_set_brightness(str
 				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 -Naurp linux-acpi-1//include/acpi/acpi_drivers.h linux-acpi-2/include/acpi/acpi_drivers.h
--- linux-acpi-1//include/acpi/acpi_drivers.h	2010-12-08 18:42:33.099000002 +0100
+++ linux-acpi-2/include/acpi/acpi_drivers.h	2010-12-08 18:42:53.628000001 +0100
@@ -119,8 +119,8 @@ void pci_acpi_crs_quirks(void);
                                   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 ha
 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_notif
 {
 }
 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;


-- 
Hanno Böck		Blog:		http://www.hboeck.de/
GPG: 3DBD3B20		Jabber/Mail:	hanno@hboeck.de

http://schokokeks.org - professional webhosting

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] acpi: const-ify functions
  2010-12-08 18:25 [PATCH] acpi: const-ify functions Hanno Böck
@ 2010-12-08 19:17 ` Alexey Dobriyan
  0 siblings, 0 replies; 2+ messages in thread
From: Alexey Dobriyan @ 2010-12-08 19:17 UTC (permalink / raw)
  To: Hanno Böck; +Cc: lenb, linux-kernel, linux-acpi

On Wed, Dec 08, 2010 at 07:25:10PM +0100, Hanno Böck wrote:
> Will const a couple of functions and variables. This is extracted
> from grsecurity (with only a slight modification to limit a line
> to 80 chars).

Why don't they do it themselves? :^)

> Patch is against linux-acpi-2.6 git.
> 
> Similar patches have been sent in the past but not applied,
> supposedly because they weren't sent to subsystem maintainers.
> (I may continue to send similar extracts to other subsystems)
> 
> ---
> Signed-off-by: Hanno Boeck <hanno@hboeck.de>

Signed-off-by should be before --- -- it must make into changelog.

> diff -Naurp linux-acpi-1//drivers/acpi/battery.c linux-acpi-2/drivers/acpi/battery.c
> --- linux-acpi-1//drivers/acpi/battery.c	2010-12-08 18:42:26.187000005 +0100
> +++ linux-acpi-2/drivers/acpi/battery.c	2010-12-08 18:42:53.595000204 +0100
> @@ -851,7 +851,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
>  	}
>  
>  static struct battery_file {
> -	struct file_operations ops;
> +	const struct file_operations ops;

Whoa, does this work?

>  	mode_t mode;
>  	const char *name;
>  } acpi_battery_file[] = {

It maybe better to call proc_create_date() by hand (and even handle
errors gracefully?
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-08 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 18:25 [PATCH] acpi: const-ify functions Hanno Böck
2010-12-08 19:17 ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox