diff --git a/Makefile.dkms b/Makefile.dkms new file mode 100644 index 0000000..3a06762 --- /dev/null +++ b/Makefile.dkms @@ -0,0 +1,24 @@ +modname := bbswitch +DKMS := dkms +modver := $(shell awk -F'"' '/define *BBSWITCH_VERSION/{print $$2}' < bbswitch.c) + +# directory in which generated files are stored +DKMS_DEST := /usr/src/$(modname)-$(modver) + +all: install + +src_install: + mkdir -p '$(DKMS_DEST)' + cp Makefile bbswitch.c '$(DKMS_DEST)' + sed 's/#MODULE_VERSION#/$(modver)/' dkms/dkms.conf > '$(DKMS_DEST)/dkms.conf' + +build: src_install + $(DKMS) build 'bbswitch/$(modver)' + +install: build + $(DKMS) install 'bbswitch/$(modver)' + +uninstall: + $(DKMS) remove bbswitch/$(modver) --all + +.PHONY: all src_install build install uninstall diff --git a/NEWS b/NEWS index 2f08c50..335e37e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Version 0.4.2 - 26 April 2012 + +* Fixed a documentation error on unload_state. +* Added Makefile.dkms and documentation for easier installation using DKMS. +* Make /proc/acpi/bbswitch world-writable +* Fix NULL pointer dereference when reporting a failure during ACPI method + evaluation. + Version 0.4.1 - 16 January 2012 * Corrected a small error that yielded an confusing error message "The discrete diff --git a/README.md b/README.md index 5376608..17bef18 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,16 @@ information. DKMS support ------------ -Change `#MODULE_VERSION#` to the current version of bbswitch. Copy the -Makefile, C source and dkms.conf file to `/usr/src/bbswitch-VERSION/` (replace -VERSION with the current version of bbswitch which has been inserted for -`#MODULE_VERSION#`. +If you have DKMS installed, you can install bbswitch in such a way that it +survives kernel upgrades. It is recommended to remove older versions of bbswitch +by running `dkms remove bbswitch/OLDVERSION --all` as root. To install the new +version, simply run: + + # make -f Makefile.dkms + +To uninstall it, run: + + # make -f Makefile.dkms uninstall Usage ----- @@ -74,7 +80,7 @@ The module has some options that control the behavior on loading and unloading: `load_state` and `unload_state`. Valid values are `-1`, `0` and `1` meaning "do not change the card state", "turn the card off" and "turn the card on" respectively. For example, if you want to have `bbswitch` disable the card -immediately when loading the module while disabling the card on unload, load the +immediately when loading the module while enabling the card on unload, load the module with: # modprobe bbswitch load_state=0 unload_state=1 diff --git a/bbswitch.c b/bbswitch.c index 269ceed..ca79e0d 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -16,10 +16,12 @@ #include #include +#define BBSWITCH_VERSION "0.4.2" + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Toggle the discrete graphics card"); MODULE_AUTHOR("Peter Lekensteyn "); -MODULE_VERSION("0.4.1"); +MODULE_VERSION(BBSWITCH_VERSION); enum { CARD_UNCHANGED = -1, @@ -69,12 +71,11 @@ static struct notifier_block nb; /* whether the card was off before suspend or not; on: 0, off: 1 */ int dis_before_suspend_disabled; -static char *buffer_to_string(const char buffer[], char *target) { +static char *buffer_to_string(const char *buffer, size_t n, char *target) { int i; - for (i=0; i