diff options
22 files changed, 973 insertions, 96 deletions
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass index a12899e2a1..16d6050573 100644 --- a/classes/package_ipk.bbclass +++ b/classes/package_ipk.bbclass @@ -32,7 +32,7 @@ python package_ipk_install () { # Generate ipk.conf if it or the stamp doesnt exist conffile = os.path.join(stagingdir,"ipkg.conf") - if not os.access(conffile, os.R_OK): + if not os.access(conffile, os.R_OK): ipkg_archs = bb.data.getVar('PACKAGE_ARCHS',d) if ipkg_archs is None: bb.error("PACKAGE_ARCHS missing") @@ -114,7 +114,7 @@ package_generate_ipkg_conf () { } python do_package_ipk () { - import sys, re, fcntl, copy + import sys, re, copy, fcntl workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: @@ -127,10 +127,6 @@ python do_package_ipk () { bb.error("DEPLOY_DIR_IPK not defined, unable to package") return - arch = bb.data.getVar('PACKAGE_ARCH', d, 1) - outdir = "%s/%s" % (outdir, arch) - bb.mkdirhier(outdir) - dvar = bb.data.getVar('D', d, 1) if not dvar: bb.error("D not defined, unable to package") @@ -160,9 +156,11 @@ python do_package_ipk () { fcntl.flock(lf.fileno(), fcntl.LOCK_UN) lf.close + for pkg in packages.split(): localdata = bb.data.createCopy(d) - root = "%s/install/%s" % (workdir, pkg) + pkgdest = bb.data.getVar('PKGDEST', d, 1) + root = "%s/%s" % (pkgdest, pkg) lf = lockfile(root + ".lock") @@ -181,7 +179,8 @@ python do_package_ipk () { bb.data.update_data(localdata) basedir = os.path.join(os.path.dirname(root)) - pkgoutdir = outdir + arch = bb.data.getVar('PACKAGE_ARCH', localdata, 1) + pkgoutdir = "%s/%s" % (outdir, arch) bb.mkdirhier(pkgoutdir) os.chdir(root) from glob import glob @@ -202,6 +201,7 @@ python do_package_ipk () { try: ctrlfile = file(os.path.join(controldir, 'control'), 'w') except OSError: + unlockfile(lf) raise bb.build.FuncFailed("unable to open control file for writing.") fields = [] @@ -235,6 +235,7 @@ python do_package_ipk () { except KeyError: (type, value, traceback) = sys.exc_info() ctrlfile.close() + unlockfile(lf) raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value) # more fields @@ -271,6 +272,7 @@ python do_package_ipk () { try: scriptfile = file(os.path.join(controldir, script), 'w') except OSError: + unlockfile(lf) raise bb.build.FuncFailed("unable to open %s script file for writing." % script) scriptfile.write(scriptvar) scriptfile.close() @@ -281,6 +283,7 @@ python do_package_ipk () { try: conffiles = file(os.path.join(controldir, 'conffiles'), 'w') except OSError: + unlockfile(lf) raise bb.build.FuncFailed("unable to open conffiles for writing.") for f in conffiles_str.split(): conffiles.write('%s\n' % f) @@ -290,6 +293,7 @@ python do_package_ipk () { ret = os.system("PATH=\"%s\" %s %s %s" % (bb.data.getVar("PATH", localdata, 1), bb.data.getVar("IPKGBUILDCMD",d,1), pkg, pkgoutdir)) if ret != 0: + unlockfile(lf) raise bb.build.FuncFailed("ipkg-build execution failed") for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: @@ -308,7 +312,10 @@ python do_package_ipk () { python () { import bb if bb.data.getVar('PACKAGES', d, True) != '': - bb.data.setVarFlag('do_package_write_ipk', 'depends', 'ipkg-utils-native:do_populate_staging fakeroot-native:do_populate_staging', d) + deps = (bb.data.getVarFlag('do_package_write_ipk', 'depends', d) or "").split() + deps.append('ipkg-utils-native:do_populate_staging') + deps.append('fakeroot-native:do_populate_staging') + bb.data.setVarFlag('do_package_write_ipk', 'depends', " ".join(deps), d) } python do_package_write_ipk () { diff --git a/conf/distro/angstrom-2007.1.conf b/conf/distro/angstrom-2007.1.conf index 4e187a6887..0d5fd4f013 100644 --- a/conf/distro/angstrom-2007.1.conf +++ b/conf/distro/angstrom-2007.1.conf @@ -237,7 +237,7 @@ DISTRO_EXTRA_RDEPENDS += "\ update-modules \ ${@base_contains("MACHINE_FEATURES", "screen", "psplash", "",d)} \ angstrom-version \ - ipkg ipkg-collateral angstrom-feed-configs \ + ipkg ipkg-collateral ${ANGSTROM_FEED_CONFIGS} \ util-linux-mount util-linux-umount \ ${EXTRA_STUFF} \ ${DEBUG_APPS} \ diff --git a/conf/distro/include/angstrom-eglibc.inc b/conf/distro/include/angstrom-eglibc.inc index 6726710aa9..837aec9f2d 100644 --- a/conf/distro/include/angstrom-eglibc.inc +++ b/conf/distro/include/angstrom-eglibc.inc @@ -5,14 +5,12 @@ PREFERRED_PROVIDER_virtual/libc = "eglibc" PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-initial = "eglibc-initial" PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/arm-angstrom-linux-gnueabi-libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/armeb-angstrom-linux-gnueabi-libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/arm-angstrom-linux-libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/powerpc-angstrom-linux-libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/mipsel-angstrom-linux-libc-for-gcc = "eglibc-intermediate" -PREFERRED_PROVIDER_virtual/sparc-angstrom-linux-libc-for-gcc = "eglibc-intermediate" - - +PREFERRED_PROVIDER_virtual/arm${TARGET_VENDOR}-linux-gnueabi-libc-for-gcc = "eglibc-intermediate" +PREFERRED_PROVIDER_virtual/armeb${TARGET_VENDOR}-linux-gnueabi-libc-for-gcc = "eglibc-intermediate" +PREFERRED_PROVIDER_virtual/arm${TARGET_VENDOR}-linux-libc-for-gcc = "eglibc-intermediate" +PREFERRED_PROVIDER_virtual/powerpc${TARGET_VENDOR}-linux-libc-for-gcc = "eglibc-intermediate" +PREFERRED_PROVIDER_virtual/mipsel${TARGET_VENDOR}-linux-libc-for-gcc = "eglibc-intermediate" +PREFERRED_PROVIDER_virtual/sparc${TARGET_VENDOR}-linux-libc-for-gcc = "eglibc-intermediate" TARGET_OS = "linux${@['','-gnueabi'][bb.data.getVar('TARGET_ARCH',d,1) in ['arm', 'armeb'] and bb.data.getVar('MACHINE',d) not in ['collie','h3600', 'h3800', 'simpad', 'htcwallaby']]}" diff --git a/contrib/python/generate-manifest-2.5.py b/contrib/python/generate-manifest-2.5.py index d4b7ea16f6..440434229c 100755 --- a/contrib/python/generate-manifest-2.5.py +++ b/contrib/python/generate-manifest-2.5.py @@ -11,7 +11,7 @@ import time VERSION = "2.5.1" # increase when touching python-core, this should be the same ml version as in python_2.5.1.bb -BASEREV = 3 +BASEREV = 5 __author__ = "Michael 'Mickey' Lauer <mickey@Vanille.de>" __version__ = "20071205" @@ -146,7 +146,7 @@ if __name__ == "__main__": # Parameters: revision, name, description, dependencies, filenames # - m.addPackage( 2, "python-core", "Python Interpreter and core modules (needed!)", "", + m.addPackage( 0, "python-core", "Python Interpreter and core modules (needed!)", "", "__future__.* copy.* copy_reg.* ConfigParser.* " + "getopt.* linecache.* new.* " + "os.* posixpath.* struct.* " + @@ -176,7 +176,7 @@ if __name__ == "__main__": m.addPackage( 0, "python-bsddb", "Python Berkeley Database Bindings", "python-core", "bsddb" ) # package - m.addPackage( 0, "python-codecs", "Python Codecs, Encodings & i18n Support", "python-core", + m.addPackage( 0, "python-codecs", "Python Codecs, Encodings & i18n Support", "python-core python-lang", "codecs.* encodings gettext.* locale.* lib-dynload/_locale.so lib-dynload/unicodedata.so stringprep.* xdrlib.*" ) m.addPackage( 0, "python-compile", "Python Bytecode Compilation Support", "python-core", @@ -261,7 +261,7 @@ if __name__ == "__main__": m.addPackage( 0, "python-unixadmin", "Python Unix Administration Support", "python-core", "lib-dynload/nis.so lib-dynload/grp.so lib-dynload/pwd.so getpass.*" ) - m.addPackage( 0, "python-netclient", "Python Internet Protocol Clients", "python-core python-datetime python-io python-lang python-logging python-mime", + m.addPackage( 0, "python-netclient", "Python Internet Protocol Clients", "python-core python-crypt python-datetime python-io python-lang python-logging python-mime", "*Cookie*.* " + "base64.* cookielib.* ftplib.* gopherlib.* hmac.* httplib.* mimetypes.* nntplib.* poplib.* smtplib.* telnetlib.* urllib.* urllib2.* urlparse.*" ) diff --git a/packages/directfb/directfb_1.1.0.bb b/packages/directfb/directfb_1.1.0.bb index 2c600b409f..daa3437aa6 100644 --- a/packages/directfb/directfb_1.1.0.bb +++ b/packages/directfb/directfb_1.1.0.bb @@ -7,7 +7,7 @@ SECTION = "libs" LICENSE = "LGPL" HOMEPAGE = "http://directfb.org" DEPENDS = "jpeg libpng freetype zlib tslib" -PR = "r1" +PR = "r2" RV = "1.1-0" SRC_URI = " \ @@ -37,6 +37,8 @@ EXTRA_OECONF = " \ do_stage() { autotools_stage_all + # fix breakage introduced with the fix-includes patch, it seems that directfb examples is the only app that looks in the wrong location :/ + ln -sf ${STAGING_LIBDIR} ${STAGING_LIBDIR}/directfb } do_install() { diff --git a/packages/enchant/enchant_1.3.0.bb b/packages/enchant/enchant_1.3.0.bb index 4e257618fb..cceceebabf 100644 --- a/packages/enchant/enchant_1.3.0.bb +++ b/packages/enchant/enchant_1.3.0.bb @@ -15,6 +15,8 @@ SRC_URI = "http://www.abisource.com/downloads/enchant/${PV}/enchant-${PV}.tar.gz EXTRA_OECONF = "--with-aspell-prefix=${STAGING_DIR_HOST}${layout_prefix} --enable-aspell --disable-binreloc" +export CXXFLAGS += " -L${STAGING_LIBDIR} -lstdc++ " + FILES_${PN} = "/usr/bin/* /usr/lib/enchant/*.so /usr/share/enchant /usr/lib/libenchant*.so.*" do_stage() { diff --git a/packages/linux/linux-2.6.23/leds-cpu-activity-powerpc.patch b/packages/linux/linux-2.6.23/leds-cpu-activity-powerpc.patch new file mode 100644 index 0000000000..b377355815 --- /dev/null +++ b/packages/linux/linux-2.6.23/leds-cpu-activity-powerpc.patch @@ -0,0 +1,46 @@ +Index: linux-2.6.23/arch/powerpc/kernel/idle.c +=================================================================== +--- linux-2.6.23.orig/arch/powerpc/kernel/idle.c 2007-10-09 22:31:38.000000000 +0200 ++++ linux-2.6.23/arch/powerpc/kernel/idle.c 2007-12-05 11:34:39.000000000 +0100 +@@ -19,6 +19,7 @@ + * 2 of the License, or (at your option) any later version. + */ + ++#include <linux/leds.h> + #include <linux/sched.h> + #include <linux/kernel.h> + #include <linux/smp.h> +@@ -50,6 +51,12 @@ + __setup("powersave=off", powersave_off); + + /* ++ * CPU activity indicator. ++ */ ++void (*leds_idle)(int is_idle); ++EXPORT_SYMBOL(leds_idle); ++ ++/* + * The body of the idle task. + */ + void cpu_idle(void) +@@ -59,6 +66,8 @@ + + set_thread_flag(TIF_POLLING_NRFLAG); + while (1) { ++ if (leds_idle) ++ leds_idle(1); + while (!need_resched() && !cpu_should_die()) { + ppc64_runlatch_off(); + +@@ -92,8 +101,11 @@ + ppc64_runlatch_on(); + if (cpu_should_die()) + cpu_die(); ++ if (leds_idle) ++ leds_idle(0); + preempt_enable_no_resched(); + schedule(); ++ + preempt_disable(); + } + } diff --git a/packages/linux/linux-2.6.23/leds-cpu-activity.patch b/packages/linux/linux-2.6.23/leds-cpu-activity.patch new file mode 100644 index 0000000000..ebdf1abd81 --- /dev/null +++ b/packages/linux/linux-2.6.23/leds-cpu-activity.patch @@ -0,0 +1,554 @@ +Index: linux-2.6.23/drivers/leds/Kconfig +=================================================================== +--- linux-2.6.23.orig/drivers/leds/Kconfig 2007-12-05 12:00:28.000000000 +0100 ++++ linux-2.6.23/drivers/leds/Kconfig 2007-12-05 13:46:39.000000000 +0100 +@@ -123,6 +123,15 @@ + This allows LEDs to be controlled by a programmable timer + via sysfs. If unsure, say Y. + ++config LEDS_TRIGGER_CPU_ACTIVITY ++ tristate "LED CPU Activity Trigger" ++ depends on LEDS_TRIGGERS ++ help ++ This allows LEDs to be set to show cpu activity via sysfs. ++ The LED will blink when the cpu is active and stay steady ++ (on or off according to the trigger selected) when idle. ++ Platform support is needed for this to work. If unsure, say Y. ++ + config LEDS_TRIGGER_IDE_DISK + bool "LED IDE Disk Trigger" + depends on LEDS_TRIGGERS && BLK_DEV_IDEDISK +Index: linux-2.6.23/drivers/leds/ledtrig-cpu.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.23/drivers/leds/ledtrig-cpu.c 2007-12-05 12:00:28.000000000 +0100 +@@ -0,0 +1,502 @@ ++/* ++ * LEDs CPU activity trigger ++ * ++ * Author: John Bowler <jbowler@acm.org> ++ * ++ * Copyright (c) 2006 John Bowler ++ * ++ * Permission is hereby granted, free of charge, to any ++ * person obtaining a copy of this software and associated ++ * documentation files (the "Software"), to deal in the ++ * Software without restriction, including without ++ * limitation the rights to use, copy, modify, merge, ++ * publish, distribute, sublicense, and/or sell copies of ++ * the Software, and to permit persons to whom the ++ * Software is furnished to do so, subject to the ++ * following conditions: ++ * ++ * The above copyright notice and this permission notice ++ * shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ++ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ++ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A ++ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT ++ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ++ * OTHER DEALINGS IN THE SOFTWARE. ++ * ++ */ ++ ++#include <linux/ctype.h> ++#include <linux/kernel.h> ++#include <linux/module.h> ++#include <linux/init.h> ++#include <linux/spinlock.h> ++#include <linux/timer.h> ++#include <linux/device.h> ++ ++#include <linux/leds.h> ++#include "leds.h" ++ ++//#include <linux/list.h> ++//#include <linux/sysdev.h> ++ ++ ++/* ++ * To simplify this the LED state is given for each case of ++ * CPU state - idle or active. The LED can be: ++ * ++ * off ++ * flash - slow for idle, fast (flicker) for active ++ * on ++ * ++ * This gives two useless states - off/off and on/on ++ */ ++typedef enum cpu_trigger_led_state { ++ cpu_led_off, ++ cpu_led_flash, ++ cpu_led_on, ++ cpu_led_invalid ++} cpu_trigger_led_state; ++ ++static const char *const cpu_trigger_names[] = { ++ "off", ++ "flash", ++ "on", ++ "invalid" ++}; ++ ++/* Forward declaration - this is called back when an LED property ++ * is changed. ++ */ ++static void leds_cpu_trigger_state_change(void); ++ ++/* ++ * These constants define the actual mark/space of the flashing ++ * in jiffies. msecs_to_jiffies rounds up and is compile time ++ * evaluable for constant arguments. Writing the ?: stuff below ++ * this way ensures the compiler doesn't think it needs to ++ * compile in the math of msecs_to_jiffies. ++ * ++ * These values have been determined by experiment to work well ++ * for the ready/status LED on a LinkSys NSLU2 (light piped) and ++ * for the user LED on a Loft (Gateway Avila variant) board where ++ * the LED was directly visible. Light Output Varies Everywhere. ++ */ ++#define LEDS_CPU_ACTIVE_MARK msecs_to_jiffies(40) ++#define LEDS_CPU_IDLE_MARK msecs_to_jiffies(800) ++#define LEDS_CPU_ACTIVE_SPACE msecs_to_jiffies(60) ++#define LEDS_CPU_IDLE_SPACE msecs_to_jiffies(800) ++ ++ ++/* ++ * Individual LEDs ------------------------------------------------------------ ++ */ ++struct cpu_trigger_data { ++ cpu_trigger_led_state active; /* Behaviour when the CPU is active. */ ++ cpu_trigger_led_state idle; /* Behaviour when the CPU is idle. */ ++}; ++ ++/* ++ * LED state change - called when the state of a single LED might ++ * have changed. Returns true if the LED is blinking. The argument ++ * is the blink state - the brightness of the blinking LED. ++ */ ++static int leds_cpu_trigger_led_state_change(struct led_classdev *led, ++ int is_active, enum led_brightness brightness) ++{ ++ int is_blinking = 0; ++ ++ struct cpu_trigger_data *data = led->trigger_data; ++ ++ /* Find the new brightness for the LED, if the LED is ++ * set to flash then the brightness passed in is the ++ * required value. ++ */ ++ if (likely(data != 0)) ++ switch (is_active ? data->active : data->idle) { ++ case cpu_led_off: brightness = LED_OFF; break; ++ case cpu_led_flash: is_blinking = 1; break; ++ case cpu_led_on: brightness = LED_FULL; break; ++ } ++ else ++ brightness = is_active ? LED_FULL : LED_OFF; ++ ++ led_set_brightness(led, brightness); ++ ++ return is_blinking; ++} ++ ++/* ++ * sysfs properties, the property is output at an list of the ++ * values with the current setting enclosed in [] ++ */ ++static ssize_t leds_cpu_trigger_show_prop(struct device *dev, ++ struct device_attribute *attr, char *buf, size_t where) ++{ ++ struct led_classdev *led = dev_get_drvdata(dev); ++ cpu_trigger_led_state item = cpu_led_invalid, i; ++ char *next; ++ ++ if (likely(led->trigger_data != 0)) ++ item = *(const cpu_trigger_led_state*)( ++ led->trigger_data + where); ++ ++ for (i=0, next=buf; i<cpu_led_invalid; ++i) { ++ const char *name = cpu_trigger_names[i]; ++ size_t len = strlen(name); ++ ++ if (i == item) ++ *next++ = '['; ++ memcpy(next, name, len); ++ next += len; ++ if (i == item) ++ *next++ = ']'; ++ *next++ = ' '; ++ } ++ ++ next[-1] = '\n'; ++ *next++ = 0; ++ ++ return next - buf; ++} ++ ++static ssize_t leds_cpu_trigger_show_active(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ return leds_cpu_trigger_show_prop(dev, attr, buf, ++ offsetof(struct cpu_trigger_data, active)); ++} ++ ++static ssize_t leds_cpu_trigger_show_idle(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ return leds_cpu_trigger_show_prop(dev, attr, buf, ++ offsetof(struct cpu_trigger_data, idle)); ++} ++ ++/* ++ * Any matching leading substring selects a property - so "onoffonoff" ++ * sets the property to off. ++ */ ++static ssize_t leds_cpu_trigger_store_prop(struct device *dev, ++ struct device_attribute *attr, const char *buf, ++ size_t size, size_t where) ++{ ++ size_t rc = 0; ++ cpu_trigger_led_state value = 0/*sic*/; ++ struct led_classdev *led; ++ ++ /* ignore space characters before the value. */ ++ while (rc < size && isspace(buf[rc])) ++ ++rc; ++ if (rc >= size) ++ return rc; ++ ++ /* look for a simple match against the trigger name, case ++ * sensitive. ++ */ ++ do { ++ const char *name = cpu_trigger_names[value]; ++ size_t len = strlen(name); ++ if (len <= size && memcmp(buf+rc, name, len) == 0) { ++ rc = len; ++ break; ++ } ++ if (++value >= cpu_led_invalid) ++ return -EINVAL; ++ } while (1); ++ ++ led = dev_get_drvdata(dev); ++ if (likely(led->trigger_data != 0)) ++ *(cpu_trigger_led_state*)( ++ led->trigger_data + where) = value; ++ ++ return rc; ++} ++ ++static ssize_t leds_cpu_trigger_store_active(struct device *dev, ++ struct device_attribute *attr, const char *buf, size_t size) ++{ ++ ssize_t rc = leds_cpu_trigger_store_prop(dev, attr, buf, size, ++ offsetof(struct cpu_trigger_data, active)); ++ /* ++ * At least one CPU must be active (otherwise who is doing this?) ++ * Call down into the global state below to cause an update ++ * to happen now. ++ */ ++ leds_cpu_trigger_state_change(); ++ return rc; ++} ++ ++static ssize_t leds_cpu_trigger_store_idle(struct device *dev, ++ struct device_attribute *attr, const char *buf, size_t size) ++{ ++ return leds_cpu_trigger_store_prop(dev, attr, buf, size, ++ offsetof(struct cpu_trigger_data, idle)); ++} ++ ++static DEVICE_ATTR(active, 0644, leds_cpu_trigger_show_active, ++ leds_cpu_trigger_store_active); ++ ++static DEVICE_ATTR(idle, 0644, leds_cpu_trigger_show_idle, ++ leds_cpu_trigger_store_idle); ++ ++/* ++ * Activate and deactivate are called on individual LEDs when the ++ * LED trigger property is changed. ++ */ ++static void leds_cpu_trigger_activate(struct led_classdev *led) ++{ ++ /* ++ * The initial setting of the trigger is simple CPU activity ++ * with the LED off for idle and on for active. Consequently ++ * there is no need to mess with the global state initially, ++ * we know the CPU is active at this moment! ++ */ ++ int rc; ++ struct cpu_trigger_data *data = kmalloc(sizeof *data, GFP_KERNEL); ++ if (unlikely(data == 0)) ++ return; ++ ++ data->active = cpu_led_on; ++ data->idle = cpu_led_off; ++ led->trigger_data = data; ++ ++ rc = device_create_file(led->dev, &dev_attr_active); ++ if (rc) ++ goto err_out; ++ rc = device_create_file(led->dev, &dev_attr_idle); ++ if (rc) ++ goto err_out_active; ++ ++ led_set_brightness(led, LED_FULL); ++ return; ++ ++err_out_active: ++ device_remove_file(led->dev, &dev_attr_active); ++err_out: ++ led->trigger_data = NULL; ++ kfree(data); ++} ++ ++static void leds_cpu_trigger_deactivate(struct led_classdev *led) ++{ ++ struct cpu_trigger_data *data = led->trigger_data; ++ if (likely(data != 0)) { ++ led_set_brightness(led, LED_OFF); ++ ++ device_remove_file(led->dev, &dev_attr_idle); ++ device_remove_file(led->dev, &dev_attr_active); ++ ++ led->trigger_data = 0; ++ kfree(data); ++ } ++} ++ ++ ++/* ++ * Global state -------------------------------------------------------------- ++ * ++ * This is global because the CPU state is global and we only need one timer to ++ * do this stuff. ++ */ ++typedef struct leds_cpu_trigger_data { ++ struct led_trigger trigger; /* the lock in here protects everything */ ++ struct timer_list timer; ++ unsigned long last_active_time; /* record of last jiffies */ ++ unsigned long last_idle_time; /* record of last jiffies */ ++ int count_active; /* number of active CPUs */ ++} leds_cpu_trigger_data; ++ ++/* ++ * Mark state - uses the current time (jiffies) to work out ++ * whether this is a mark or space. ++ */ ++static int leds_cpu_trigger_mark(struct leds_cpu_trigger_data *data, ++ unsigned long now) { ++ if (data->count_active > 0) { ++ unsigned long elapsed = now - data->last_active_time; ++ elapsed %= LEDS_CPU_ACTIVE_SPACE + LEDS_CPU_ACTIVE_MARK; ++ data->last_active_time = now - elapsed; ++ return elapsed > LEDS_CPU_ACTIVE_SPACE; ++ } else { ++ unsigned long elapsed = now - data->last_idle_time; ++ elapsed %= LEDS_CPU_IDLE_SPACE + LEDS_CPU_IDLE_MARK; ++ data->last_idle_time = now - elapsed; ++ return elapsed > LEDS_CPU_IDLE_SPACE; ++ } ++} ++ ++ ++/* ++ * State change - given information about the nature of the ++ * (possible) state change call up to each LED to adjust its ++ * state. Returns true if any LED is blinking. The lock ++ * must be held (a read lock is adequate). ++ */ ++static int leds_cpu_trigger_scan_leds(struct leds_cpu_trigger_data *data, ++ unsigned long now) ++{ ++ int blinking = 0; ++ const int active = data->count_active > 0; ++ const enum led_brightness brightness = ++ leds_cpu_trigger_mark(data, now) ? LED_FULL : LED_OFF; ++ struct list_head *entry; ++ ++ list_for_each(entry, &data->trigger.led_cdevs) { ++ struct led_classdev *led = ++ list_entry(entry, struct led_classdev, trig_list); ++ ++ blinking |= leds_cpu_trigger_led_state_change(led, ++ active, brightness); ++ } ++ ++ return blinking; ++} ++ ++/* ++ * Set the timer correctly according to the current state, the lock ++ * must be held for write. ++ */ ++static void leds_cpu_trigger_set_timer(struct leds_cpu_trigger_data *state, ++ unsigned long now) ++{ ++ unsigned long next; ++ if (state->count_active > 0) { ++ next = state->last_active_time; ++ if (now - next > LEDS_CPU_ACTIVE_SPACE) ++ next += LEDS_CPU_ACTIVE_MARK; ++ next += LEDS_CPU_ACTIVE_SPACE; ++ } else { ++ next = state->last_idle_time; ++ if (now - next > LEDS_CPU_IDLE_SPACE) ++ next += LEDS_CPU_IDLE_MARK; ++ next += LEDS_CPU_IDLE_SPACE; ++ } ++ mod_timer(&state->timer, next); ++} ++ ++/* ++ * The timer callback if the LED is currently flashing, the callback ++ * calls the state change function and, if that returns true, meaning ++ * that at least one LED is still blinking, the timer is restarted ++ * with the correct timeout. ++ */ ++static void leds_cpu_trigger_timer_callback(unsigned long data) ++{ ++ struct leds_cpu_trigger_data *state = ++ (struct leds_cpu_trigger_data *)data; ++ ++ write_lock(&state->trigger.leddev_list_lock); ++ { ++ unsigned long now = jiffies; ++ ++ /* If at least one LED is set to flash; set the timer ++ * again (this won't reset the timer set within the ++ * idle loop). ++ */ ++ if (leds_cpu_trigger_scan_leds(state, now)) ++ leds_cpu_trigger_set_timer(state, now); ++ } ++ write_unlock(&state->trigger.leddev_list_lock); ++} ++ ++ ++/* ++ * There is one global control structure, one timer and one set ++ * of state for active CPUs shared across all the LEDs. Individual ++ * LEDs say how this state to be handled. It is currently *not* ++ * possible to show per-cpu activity on individual LEDs, the code ++ * maintains a count of active CPUs and the state is only 'idle' ++ * if all CPUs are idle. ++ */ ++static struct leds_cpu_trigger_data leds_cpu_trigger = { ++ .trigger = { ++ .name = "cpu", ++ .activate = leds_cpu_trigger_activate, ++ .deactivate = leds_cpu_trigger_deactivate, ++ } , ++ .timer = TIMER_INITIALIZER(leds_cpu_trigger_timer_callback, 0, ++ (unsigned long)&leds_cpu_trigger), ++ .last_active_time = 0, ++ .last_idle_time = 0, ++ .count_active = 0, ++}; ++ ++/* ++ * State change - callback from an individual LED on a property change which ++ * might require a redisplay. ++ */ ++static void leds_cpu_trigger_state_change() { ++ write_lock(&leds_cpu_trigger.trigger.leddev_list_lock); ++ { ++ unsigned long now = jiffies; ++ ++ if (leds_cpu_trigger_scan_leds(&leds_cpu_trigger, now) && ++ !timer_pending(&leds_cpu_trigger.timer)) ++ leds_cpu_trigger_set_timer(&leds_cpu_trigger, now); ++ } ++ write_unlock(&leds_cpu_trigger.trigger.leddev_list_lock); ++} ++ ++/* ++ * Called from every CPU at the start and end of the idle loop. ++ * The active count is initially 0, even though CPUs are running, ++ * so the code below must check for the resultant underflow. ++ * ++ * If the idle behaviour is 'flash' then when the timer times out ++ * it will take the CPU out of idle, set the active state (which ++ * may also be flash), drop back into idle and reset the timer to ++ * the idle timeout... ++ */ ++static void leds_cpu_trigger_idle(int is_idle) ++{ ++ write_lock(&leds_cpu_trigger.trigger.leddev_list_lock); ++ if ((is_idle && leds_cpu_trigger.count_active > 0 && ++ --leds_cpu_trigger.count_active == 0) || ++ (!is_idle && leds_cpu_trigger.count_active < num_online_cpus() && ++ ++leds_cpu_trigger.count_active == 1)) { ++ unsigned long now = jiffies; ++ ++ /* State change - the system just became idle or active, ++ * call the del_timer first in an attempt to minimise ++ * getting a timer interrupt which will take us unnecessarily ++ * out of idle (this doesn't matter). ++ */ ++ del_timer(&leds_cpu_trigger.timer); ++ if (leds_cpu_trigger_scan_leds(&leds_cpu_trigger, now)) ++ leds_cpu_trigger_set_timer(&leds_cpu_trigger, now); ++ } ++ write_unlock(&leds_cpu_trigger.trigger.leddev_list_lock); ++} ++ ++/* ++ * Module init and exit - register the trigger, then store ++ * the idle callback in the arch-specific global. For this ++ * module to link (into the kernel) or load (into a running ++ * kernel) the architecture must define the leds_idle global. ++ */ ++static int __init leds_cpu_trigger_init(void) ++{ ++ int rc = led_trigger_register(&leds_cpu_trigger.trigger); ++ leds_idle = leds_cpu_trigger_idle; ++ return rc; ++} ++module_init(leds_cpu_trigger_init); ++ ++static void __exit leds_cpu_trigger_exit(void) ++{ ++ leds_idle = 0; ++ del_timer_sync(&leds_cpu_trigger.timer); ++ led_trigger_unregister(&leds_cpu_trigger.trigger); ++} ++module_exit(leds_cpu_trigger_exit); ++ ++MODULE_AUTHOR("John Bowler <jbowler@acm.org>"); ++MODULE_DESCRIPTION("CPU activity LED trigger"); ++MODULE_LICENSE("Dual MIT/GPL"); +Index: linux-2.6.23/drivers/leds/Makefile +=================================================================== +--- linux-2.6.23.orig/drivers/leds/Makefile 2007-12-05 12:00:28.000000000 +0100 ++++ linux-2.6.23/drivers/leds/Makefile 2007-12-05 12:00:28.000000000 +0100 +@@ -23,3 +23,4 @@ + obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o + obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o + obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o ++obj-$(CONFIG_LEDS_TRIGGER_CPU_ACTIVITY) += ledtrig-cpu.o +Index: linux-2.6.23/include/linux/leds.h +=================================================================== +--- linux-2.6.23.orig/include/linux/leds.h 2007-10-09 22:31:38.000000000 +0200 ++++ linux-2.6.23/include/linux/leds.h 2007-12-05 12:00:28.000000000 +0100 +@@ -123,4 +123,13 @@ + }; + + ++/* ++ * CPU activity indication. ++ */ ++/* Idle callback - call with is_idle==1 at the start of the idle loop ++ * and with is_idle==0 at the end. This symbol must be defined by ++ * the arch core to be able to use LEDS_TRIGGER_CPU_ACTIVITY ++ */ ++extern void (*leds_idle)(int is_idle); ++ + #endif /* __LINUX_LEDS_H_INCLUDED */ |
