From patchwork Mon Jun 27 08:29:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2319 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0BE0123FA4 for ; Mon, 27 Jun 2011 08:30:49 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id C8A13A18766 for ; Mon, 27 Jun 2011 08:30:48 +0000 (UTC) Received: by qyk10 with SMTP id 10so389155qyk.11 for ; Mon, 27 Jun 2011 01:30:48 -0700 (PDT) Received: by 10.229.40.139 with SMTP id k11mr4390710qce.135.1309163448076; Mon, 27 Jun 2011 01:30:48 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.230.139 with SMTP id jm11cs42756qcb; Mon, 27 Jun 2011 01:30:47 -0700 (PDT) Received: by 10.217.0.211 with SMTP id l61mr4624154wes.73.1309163446727; Mon, 27 Jun 2011 01:30:46 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by mx.google.com with ESMTP id e43si10721993wes.81.2011.06.27.01.30.46; Mon, 27 Jun 2011 01:30:46 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.131 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.131; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.131 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.136.72.96]) by mwinf5d32 with ME id 0wWl1h00224eYqc03wWl2Z; Mon, 27 Jun 2011 10:30:46 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Cc: patches@linaro.org, woogyom.kim@gmail.com Subject: [powerdebug] fix segfault when no clock is available Date: Mon, 27 Jun 2011 10:29:05 +0200 Message-Id: <1309163345-10036-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 When there is no clock available, we even register the display ops. The 'enter' callbakc is set but not data is available int the row private data which leads to a segfaults. This patch fix this problem by not registering the ops if the pm subsystem was not correctly initialized. In the meantime, we have to erase the window when we are switching from one window to another. We can say it is the "default" display callback. Signed-off-by: Daniel Lezcano Reported-by: Milo (Woogyom) Kim --- clocks.c | 8 ++++---- display.c | 5 ++++- regulator.c | 8 ++++---- sensor.c | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/clocks.c b/clocks.c index 0bd0a0e..20a245c 100644 --- a/clocks.c +++ b/clocks.c @@ -405,9 +405,6 @@ int clock_init(void) { char clk_dir_path[PATH_MAX]; - if (display_register(CLOCK, &clock_ops)) - return -1; - if (locate_debugfs(clk_dir_path)) return -1; @@ -420,5 +417,8 @@ int clock_init(void) if (!clock_tree) return -1; - return fill_clock_tree(); + if (fill_clock_tree()) + return -1; + + return display_register(CLOCK, &clock_ops); } diff --git a/display.c b/display.c index 0cfbf94..ebc4de6 100644 --- a/display.c +++ b/display.c @@ -120,7 +120,10 @@ static int display_refresh(int win, bool read) if (windata[win].ops && windata[win].ops->display) return windata[win].ops->display(read); - return 0; + if (werase(main_win)) + return -1; + + return wrefresh(main_win); } int display_refresh_pad(int win) diff --git a/regulator.c b/regulator.c index 849f906..e9b01bb 100644 --- a/regulator.c +++ b/regulator.c @@ -236,12 +236,12 @@ static struct display_ops regulator_ops = { int regulator_init(void) { - if (display_register(REGULATOR, ®ulator_ops)) - return -1; - reg_tree = tree_load(SYSFS_REGULATOR, regulator_filter_cb); if (!reg_tree) return -1; - return fill_regulator_tree(); + if (fill_regulator_tree()) + return -1; + + return display_register(REGULATOR, ®ulator_ops); } diff --git a/sensor.c b/sensor.c index d63510e..e172f88 100644 --- a/sensor.c +++ b/sensor.c @@ -271,12 +271,12 @@ static struct display_ops sensor_ops = { int sensor_init(void) { - if (display_register(SENSOR, &sensor_ops)) - return -1; - sensor_tree = tree_load(SYSFS_SENSOR, sensor_filter_cb); if (!sensor_tree) return -1; - return fill_sensor_tree(); + if (fill_sensor_tree()) + return -1; + + return display_register(SENSOR, &sensor_ops); }