Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r2130 - in trunk/src/target/gsm: include/gsmd src/gsmd
      ([EMAIL PROTECTED])
   2. r2131 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
   3. r2132 - trunk/oe/packages/gsm ([EMAIL PROTECTED])
   4. r2133 - trunk/src/target/kernel/patches
      ([EMAIL PROTECTED])
   5. r2134 - trunk/src/target/kernel/patches
      ([EMAIL PROTECTED])
   6. r2135 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
--- Begin Message ---
Author: laforge
Date: 2007-06-02 15:45:46 +0200 (Sat, 02 Jun 2007)
New Revision: 2130

Added:
   trunk/src/target/gsm/src/gsmd/timer.c
Modified:
   trunk/src/target/gsm/include/gsmd/gsmd.h
   trunk/src/target/gsm/src/gsmd/Makefile.am
   trunk/src/target/gsm/src/gsmd/gsmd.c
Log:
Add 'modem alive' detection.  We inquire every five minutes if the modem is 
still alive.


Modified: trunk/src/target/gsm/include/gsmd/gsmd.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/gsmd.h    2007-06-02 12:11:46 UTC (rev 
2129)
+++ trunk/src/target/gsm/include/gsmd/gsmd.h    2007-06-02 13:45:46 UTC (rev 
2130)
@@ -98,6 +98,27 @@
 
 extern int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt);
 
+/***********************************************************************
+ * timer handling
+ ***********************************************************************/
+
+struct gsmd_timer {
+       struct llist_head list;
+       struct timeval expires;
+       void (*cb)(struct gsmd_timer *tmr, void *data);
+       void *data;
+};
+
+int gsmd_timer_init(void);
+void gmsd_timer_check_n_run(void);
+
+struct gsmd_timer *gsmd_timer_alloc(void);
+int gsmd_timer_register(struct gsmd_timer *timer);
+void gsmd_timer_unregister(struct gsmd_timer *timer);
+
+struct gsmd_timer *gsmd_timer_create(struct timeval *expires,
+                                    void (*cb)(struct gsmd_timer *tmr, void 
*data), void *data);
+#define gsmd_timer_free(x) talloc_free(x)
 #endif /* __GSMD__ */
 
 #endif /* _GSMD_H */

Modified: trunk/src/target/gsm/src/gsmd/Makefile.am
===================================================================
--- trunk/src/target/gsm/src/gsmd/Makefile.am   2007-06-02 12:11:46 UTC (rev 
2129)
+++ trunk/src/target/gsm/src/gsmd/Makefile.am   2007-06-02 13:45:46 UTC (rev 
2130)
@@ -6,7 +6,7 @@
 
 gsmd_CFLAGS = -D PLUGINDIR=\"$(plugindir)\"
 gsmd_SOURCES = gsmd.c atcmd.c select.c machine.c vendor.c unsolicited.c log.c \
-              usock.c talloc.c operator_cache.c ext_response.c
+              usock.c talloc.c timer.c operator_cache.c ext_response.c
 gsmd_LDADD = -ldl
 gsmd_LDFLAGS = -Wl,--export-dynamic
 

Modified: trunk/src/target/gsm/src/gsmd/gsmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/gsmd.c        2007-06-02 12:11:46 UTC (rev 
2129)
+++ trunk/src/target/gsm/src/gsmd/gsmd.c        2007-06-02 13:45:46 UTC (rev 
2130)
@@ -44,9 +44,111 @@
 #include <gsmd/vendorplugin.h>
 #include <gsmd/talloc.h>
 
+#define GSMD_ALIVECMD          "ATE0"
+#define GSMD_ALIVE_INTERVAL    5*60
+#define GSMD_ALIVE_TIMEOUT     30
+
+/* alive checking */
+
+struct gsmd_alive_priv {
+       struct gsmd *gsmd;
+       int alive_responded;
+};
+
+static int gsmd_alive_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       struct gsmd_alive_priv *alp = ctx;
+
+       DEBUGP("alp=%p - `%s' returned `%s'\n", alp, cmd->buf, resp);
+       if (!strcmp(resp, "OK")) {
+               DEBUGP("`%s' returned `%s': OK\n", cmd->buf, resp);
+               alp->alive_responded = 1;
+       }
+       return 0;
+}
+
+static void alive_tmr_cb(struct gsmd_timer *tmr, void *data)
+{
+       struct gsmd_alive_priv *alp = data;
+
+       DEBUGP("alp=%p gsmd_alive timer expired\n", alp);
+
+       if (alp->alive_responded == 0) {
+               DEBUGP("modem dead!\n");
+               exit(3);
+       } else
+               DEBUGP("modem alive!\n");
+
+       /* FIXME: update some global state */
+
+       gsmd_timer_free(tmr);
+       talloc_free(alp);
+}
+
+static int gsmd_modem_alive(struct gsmd *gsmd)
+{
+       struct gsmd_atcmd *cmd;
+       struct gsmd_alive_priv *alp;
+       struct timeval tv;
+
+       alp = talloc(gsmd_tallocs, struct gsmd_alive_priv);
+       if (!alp)
+               return -ENOMEM;
+
+       alp->gsmd = gsmd;
+       alp->alive_responded = 0;
+
+       tv.tv_sec = GSMD_ALIVE_TIMEOUT;
+       cmd = atcmd_fill(GSMD_ALIVECMD, strlen(GSMD_ALIVECMD)+1, 
+                        &gsmd_alive_cb, alp, 0);
+       if (!cmd) {
+               talloc_free(alp);
+               return -ENOMEM;
+       }
+
+       tv.tv_usec = 0;
+       gsmd_timer_create(&tv, &alive_tmr_cb, alp);
+       
+       return atcmd_submit(gsmd, cmd);
+}
+
+static void alive_interval_tmr_cb(struct gsmd_timer *tmr, void *data)
+{
+       struct gsmd *gsmd = data;
+
+       DEBUGP("interval expired, starting next alive inquiry\n");
+
+       /* start a new alive check iteration */
+       gsmd_modem_alive(gsmd);
+
+       /* re-add the timer for the next interval */
+       tmr->expires.tv_sec = GSMD_ALIVE_INTERVAL;
+       tmr->expires.tv_usec = 0;
+
+       gsmd_timer_register(tmr);
+}
+
+static int gmsd_alive_start(struct gsmd *gsmd)
+{
+       struct timeval tv;
+
+       tv.tv_sec = GSMD_ALIVE_INTERVAL;
+       tv.tv_usec = 0;
+
+       if (!gsmd_timer_create(&tv, &alive_interval_tmr_cb, gsmd))
+               return -1;
+
+       gsmd_modem_alive(gsmd);
+
+       return 0;
+}
+
+
+/* initial startup code */
+
 static int gsmd_test_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
-       printf("`%s' returned `%s'\n", cmd->buf, resp);
+       DEBUGP("`%s' returned `%s'\n", cmd->buf, resp);
        return 0;
 }
 
@@ -60,7 +162,7 @@
        return atcmd_submit(gsmd, cmd);
 }
 
-int gsmd_initsettings(struct gsmd *gsmd)
+static int gsmd_initsettings2(struct gsmd *gsmd)
 {
        int rc;
        
@@ -92,6 +194,28 @@
                return rc;
 }
 
+/* we submit the first atcmd and wait synchronously for a valid response */
+static int firstcmd_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       struct gsmd *gsmd = ctx;
+       DEBUGP("`%s' returned `%s'\n", cmd->buf, resp);
+       if (strcmp(resp, "OK")) {
+               fprintf(stderr, "response '%s' to initial command invalid", 
resp);
+               exit(1);
+       }
+       return gsmd_initsettings2(gsmd);
+}
+
+int gsmd_initsettings(struct gsmd *gsmd)
+{
+       struct gsmd_atcmd *cmd;
+       cmd = atcmd_fill("ATE0V1", strlen("ATE0V1")+1, &firstcmd_atcb, gsmd, 0);
+       if (!cmd)
+               return -ENOMEM;
+       
+       return atcmd_submit(gsmd, cmd);
+}
+
 struct bdrt {
        int bps;
        u_int32_t b;
@@ -195,6 +319,8 @@
                break;
        case SIGUSR1:
                talloc_report_full(gsmd_tallocs, stderr);
+       case SIGALRM:
+               gsmd_timer_check_n_run();
                break;
        }
 }
@@ -215,6 +341,7 @@
        signal(SIGINT, sig_handler);
        signal(SIGSEGV, sig_handler);
        signal(SIGUSR1, sig_handler);
+       signal(SIGALRM, sig_handler);
        
        gsmd_tallocs = talloc_named_const(NULL, 1, "GSMD");
 
@@ -285,6 +412,8 @@
                exit(1);
        }
 
+       gsmd_timer_init();
+
        if (gsmd_machine_plugin_init(&g, machine_name, vendor_name) < 0) {
                fprintf(stderr, "no machine plugins found\n");
                exit(1);
@@ -326,6 +455,8 @@
 
        if (g.interpreter_ready)
                gsmd_initsettings(&g);
+       
+       gmsd_alive_start(&g);
 
        gsmd_opname_init(&g);
 
@@ -335,7 +466,7 @@
                        continue;
 
                if (ret < 0) {
-                       if (errno == -EINTR)
+                       if (errno == EINTR)
                                continue;
                        else {
                                DEBUGP("select returned error (%s)\n",

Added: trunk/src/target/gsm/src/gsmd/timer.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/timer.c       2007-06-02 12:11:46 UTC (rev 
2129)
+++ trunk/src/target/gsm/src/gsmd/timer.c       2007-06-02 13:45:46 UTC (rev 
2130)
@@ -0,0 +1,217 @@
+/* gsmd timer code
+ *
+ * (C) 2000-2005 by Harald Welte <[EMAIL PROTECTED]>
+ * (C) 2007 by OpenMoko, Inc.
+ * Written by Harald Welte <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include <common/linux_list.h>
+
+#include "gsmd.h"
+
+#include <gsmd/gsmd.h>
+#include <gsmd/talloc.h>
+
+static LLIST_HEAD(gsmd_timers);
+static void *__tmr_ctx;
+
+static void tv_normalize(struct timeval *out)
+{
+       out->tv_sec += (out->tv_usec / 1000000);
+       out->tv_usec = (out->tv_usec % 1000000);
+}
+
+/* subtract two struct timevals */
+static int tv_sub(struct timeval *res, const struct timeval *from,
+                 const struct timeval *sub)
+{
+       res->tv_sec = from->tv_sec - sub->tv_sec;
+       res->tv_usec = from->tv_usec - sub->tv_usec;
+
+       while (res->tv_usec < 0) {
+               res->tv_sec -= 1;
+               res->tv_usec += 1000000;
+       }
+
+       return 0;
+}
+
+static int tv_add(struct timeval *res, const struct timeval *a1,
+                 const struct timeval *a2)
+{
+       unsigned int carry;
+
+       res->tv_sec = a1->tv_sec + a2->tv_sec;
+       res->tv_usec = a1->tv_usec + a2->tv_usec;
+
+       tv_normalize(res);
+}
+
+static int tv_later(const struct timeval *expires, const struct timeval *now)
+{
+       if (expires->tv_sec < now->tv_sec)
+               return 0;
+       else if (expires->tv_sec > now->tv_sec)
+               return 1;
+       else /* if (expires->tv_sec == now->tv_sec */ {
+               if (expires->tv_usec >= now->tv_usec)
+                       return 1;
+       }
+
+       return 0;
+}
+
+static int tv_smaller(const struct timeval *t1, const struct timeval *t2)
+{
+       return tv_later(t2, t1);
+}
+
+static int calc_next_expiration(void)
+{
+       struct gsmd_timer *cur;
+       struct timeval min, now, diff;
+       struct itimerval iti;
+       int ret;
+
+       gettimeofday(&now, NULL);
+
+retry:
+       if (llist_empty(&gsmd_timers))
+               return 0;
+
+       llist_for_each_entry(cur, &gsmd_timers, list) {
+               if (gsmd_timers.next == &cur->list)
+                       min = cur->expires;
+
+               if (tv_smaller(&cur->expires, &min))
+                       min = cur->expires;
+       }
+
+       if (tv_sub(&diff, &min, &now) < 0) {
+               /* FIXME: run expired timer callbacks */
+               /* we cannot run timers from here since we might be
+                * called from register_timer() within check_n_run() */
+
+               /* FIXME: restart with next minimum timer */
+               goto retry;
+       }
+
+       /* re-set kernel timer */
+       memset(&iti, 0, sizeof(iti));
+       memcpy(&iti.it_value, &diff, sizeof(iti.it_value));
+       ret = setitimer(ITIMER_REAL, &iti, NULL);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+void gsmd_timer_check_n_run(void)
+{
+       struct gsmd_timer *cur, *cur2;
+       struct timeval now;
+
+       if (gettimeofday(&now, NULL) < 0)
+               return;
+
+       llist_for_each_entry_safe(cur, cur2, &gsmd_timers, list) {
+               if (tv_later(&now, &cur->expires)) {
+                       /* fist delete it from the list of timers */
+                       llist_del(&cur->list);
+                       /* then call.  called function can re-add it */
+                       (cur->cb)(cur, cur->data);
+               }
+       }
+
+       calc_next_expiration();
+}
+
+int gsmd_timer_init(void)
+{
+       __tmr_ctx = talloc_named_const(gsmd_tallocs, 1, "timers");
+
+       return 0;
+}
+
+struct gsmd_timer *gsmd_timer_alloc(void)
+{
+       struct gsmd_timer *tmr;
+
+       tmr = talloc_size(__tmr_ctx, sizeof(*tmr));
+       return tmr;
+}
+
+int gsmd_timer_register(struct gsmd_timer *timer)
+{
+       int ret;
+       struct timeval tv;
+
+       ret = gettimeofday(&tv, NULL);
+       if (ret < 0)
+               return ret;
+
+       /* convert expiration time into absoulte time */
+       timer->expires.tv_sec += tv.tv_sec;
+       timer->expires.tv_usec += tv.tv_usec;
+
+       llist_add_tail(&timer->list, &gsmd_timers);
+
+       /* re-calculate next expiration */
+       calc_next_expiration();
+
+       return 0;
+}
+
+struct gsmd_timer *gsmd_timer_create(struct timeval *expires,
+                                    void (*cb)(struct gsmd_timer *tmr,
+                                               void *data),
+                                    void *data)
+{
+       struct gsmd_timer *tmr = gsmd_timer_alloc();
+       int rc;
+
+       if (!tmr)
+               return NULL;
+
+       memcpy(&tmr->expires, expires, sizeof(tmr->expires));
+       tmr->cb = cb;
+       tmr->data = data;
+
+       rc = gsmd_timer_register(tmr);
+       if (rc < 0) {
+               talloc_free(tmr);
+               return NULL;
+       }
+
+       return tmr;
+}
+
+void gsmd_timer_unregister(struct gsmd_timer *timer)
+{
+       llist_del(&timer->list);
+
+       /* re-calculate next expiration */
+       calc_next_expiration();
+}




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-06-02 16:00:28 +0200 (Sat, 02 Jun 2007)
New Revision: 2131

Modified:
   trunk/src/target/gsm/src/gsmd/gsmd.c
Log:
* add timeout to initial modem detection
* make sure we only fork into background after the modem has been detected
* clean up the loglevel of some log statements


Modified: trunk/src/target/gsm/src/gsmd/gsmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/gsmd.c        2007-06-02 13:45:46 UTC (rev 
2130)
+++ trunk/src/target/gsm/src/gsmd/gsmd.c        2007-06-02 14:00:28 UTC (rev 
2131)
@@ -48,6 +48,9 @@
 #define GSMD_ALIVE_INTERVAL    5*60
 #define GSMD_ALIVE_TIMEOUT     30
 
+static struct gsmd g;
+static int daemonize = 0;
+
 /* alive checking */
 
 struct gsmd_alive_priv {
@@ -59,11 +62,8 @@
 {
        struct gsmd_alive_priv *alp = ctx;
 
-       DEBUGP("alp=%p - `%s' returned `%s'\n", alp, cmd->buf, resp);
-       if (!strcmp(resp, "OK")) {
-               DEBUGP("`%s' returned `%s': OK\n", cmd->buf, resp);
+       if (!strcmp(resp, "OK"))
                alp->alive_responded = 1;
-       }
        return 0;
 }
 
@@ -71,13 +71,13 @@
 {
        struct gsmd_alive_priv *alp = data;
 
-       DEBUGP("alp=%p gsmd_alive timer expired\n", alp);
+       DEBUGP("gsmd_alive timer expired\n", alp);
 
        if (alp->alive_responded == 0) {
-               DEBUGP("modem dead!\n");
+               gsmd_log(GSMD_FATAL, "modem dead!\n");
                exit(3);
        } else
-               DEBUGP("modem alive!\n");
+               gsmd_log(GSMD_INFO, "modem alive!\n");
 
        /* FIXME: update some global state */
 
@@ -98,7 +98,6 @@
        alp->gsmd = gsmd;
        alp->alive_responded = 0;
 
-       tv.tv_sec = GSMD_ALIVE_TIMEOUT;
        cmd = atcmd_fill(GSMD_ALIVECMD, strlen(GSMD_ALIVECMD)+1, 
                         &gsmd_alive_cb, alp, 0);
        if (!cmd) {
@@ -106,6 +105,7 @@
                return -ENOMEM;
        }
 
+       tv.tv_sec = GSMD_ALIVE_TIMEOUT;
        tv.tv_usec = 0;
        gsmd_timer_create(&tv, &alive_tmr_cb, alp);
        
@@ -194,25 +194,55 @@
                return rc;
 }
 
+static int firstcmd_response = 0;
+
 /* we submit the first atcmd and wait synchronously for a valid response */
 static int firstcmd_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
        struct gsmd *gsmd = ctx;
-       DEBUGP("`%s' returned `%s'\n", cmd->buf, resp);
+
        if (strcmp(resp, "OK")) {
-               fprintf(stderr, "response '%s' to initial command invalid", 
resp);
-               exit(1);
+               gsmd_log(GSMD_FATAL, "response '%s' to initial command 
invalid", resp);
+               exit(5);
        }
+
+       firstcmd_response = 1;
+
+       if (daemonize) {
+               if (fork()) {
+                       exit(0);
+               }
+               fclose(stdout);
+               fclose(stderr);
+               fclose(stdin);
+               setsid();
+       }
+
        return gsmd_initsettings2(gsmd);
 }
 
+static void firstcmd_tmr_cb(struct gsmd_timer *tmr, void *data)
+{
+       if (firstcmd_response == 0) {
+               gsmd_log(GSMD_FATAL, "No response from GSM Modem");
+               exit(4);
+       }
+       gsmd_timer_free(tmr);
+}
+
 int gsmd_initsettings(struct gsmd *gsmd)
 {
        struct gsmd_atcmd *cmd;
+       struct timeval tv;
+
        cmd = atcmd_fill("ATE0V1", strlen("ATE0V1")+1, &firstcmd_atcb, gsmd, 0);
        if (!cmd)
                return -ENOMEM;
        
+       tv.tv_sec = GSMD_ALIVE_TIMEOUT;
+       tv.tv_usec = 0;
+       gsmd_timer_create(&tv, &firstcmd_tmr_cb, NULL);
+
        return atcmd_submit(gsmd, cmd);
 }
 
@@ -263,9 +293,6 @@
        return tcsetattr(fd, 0, &ti);
 }
 
-
-static struct gsmd g;
-
 static int gsmd_initialize(struct gsmd *g)
 {
        INIT_LLIST_HEAD(&g->users);
@@ -329,7 +356,6 @@
 {
        int fd, argch; 
 
-       int daemonize = 0;
        int bps = 115200;
        int hwflow = 0;
        char *device = NULL;
@@ -440,16 +466,6 @@
                exit(1);
        }
 
-       if (daemonize) {
-               if (fork()) {
-                       exit(0);
-               }
-               fclose(stdout);
-               fclose(stderr);
-               fclose(stdin);
-               setsid();
-       }
-
        /* select a vendor plugin */
        gsmd_vendor_plugin_find(&g);
 




--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-06-02 16:16:35 +0200 (Sat, 02 Jun 2007)
New Revision: 2132

Modified:
   trunk/oe/packages/gsm/libgsmd_svn.bb
Log:
make sure the new gsmd plugins are put into the gsmd package


Modified: trunk/oe/packages/gsm/libgsmd_svn.bb
===================================================================
--- trunk/oe/packages/gsm/libgsmd_svn.bb        2007-06-02 14:00:28 UTC (rev 
2131)
+++ trunk/oe/packages/gsm/libgsmd_svn.bb        2007-06-02 14:16:35 UTC (rev 
2132)
@@ -4,7 +4,7 @@
 SECTION = "libs/gsm"
 PROVIDES += "gsmd"
 PV = "0.0+svn${SRCDATE}"
-PR = "r8"
+PR = "r9"
 
 SRC_URI = "svn://svn.openmoko.org/trunk/src/target;module=gsm;proto=http \
            file://gsmd"
@@ -27,7 +27,7 @@
 PACKAGES =+ "${PN}-tools gsmd"
 RDEPENDS_${PN} = "gsmd"
 FILES_${PN}-tools = "${bindir}/*"
-FILES_gsmd = "${sbindir}/gsmd ${sysconfdir}"
+FILES_gsmd = "${sbindir}/gsmd ${libdir}/gsmd ${sysconfdir}"
 
 PACKAGES_DYNAMIC = "libgsmd* gsmd"
 




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-06-02 18:45:33 +0200 (Sat, 02 Jun 2007)
New Revision: 2133

Modified:
   trunk/src/target/kernel/patches/gta01-pcf50606.patch
Log:
fix race condition in pcf50606_detect() (Andrzej Zaborowski)


Modified: trunk/src/target/kernel/patches/gta01-pcf50606.patch
===================================================================
--- trunk/src/target/kernel/patches/gta01-pcf50606.patch        2007-06-02 
14:16:35 UTC (rev 2132)
+++ trunk/src/target/kernel/patches/gta01-pcf50606.patch        2007-06-02 
16:45:33 UTC (rev 2133)
@@ -1,9 +1,9 @@
 This is the PCF50606 power management unit driver for FIC GTA01
 
-Index: linux-2.6.21-moko/drivers/i2c/chips/pcf50606.c
+Index: linux-2.6.21.3-moko/drivers/i2c/chips/pcf50606.c
 ===================================================================
 --- /dev/null
-+++ linux-2.6.21-moko/drivers/i2c/chips/pcf50606.c
++++ linux-2.6.21.3-moko/drivers/i2c/chips/pcf50606.c
 @@ -0,0 +1,1929 @@
 +/* Philips PCF50606 Power Management Unit (PMU) driver
 + *
@@ -1608,8 +1608,6 @@
 +              goto exit_free;
 +      }
 +
-+      pcf50606_global = data;
-+
 +      populate_sysfs_group(data);
 +
 +      err = sysfs_create_group(&new_client->dev.kobj, &pcf_attr_group);
@@ -1656,6 +1654,8 @@
 +              dev_err(&new_client->dev, "IRQ %u cannot be enabled as wake-up"
 +                      "source in this hardware revision!", irq);
 +
++      pcf50606_global = data;
++
 +      if (data->pdata->used_features & PCF50606_FEAT_RTC) {
 +              data->rtc = rtc_device_register("pcf50606", &new_client->dev,
 +                                              &pcf50606_rtc_ops, THIS_MODULE);
@@ -1732,16 +1732,16 @@
 +              rtc_device_unregister(pcf50606_global->rtc);
 +exit_irq:
 +      free_irq(pcf50606_global->irq, pcf50606_global);
++      pcf50606_global = NULL;
 +exit_input:
 +      pm_power_off = NULL;
-+      input_unregister_device(pcf50606_global->input_dev);
++      input_unregister_device(data->input_dev);
 +exit_sysfs:
 +      sysfs_remove_group(&new_client->dev.kobj, &pcf_attr_group);
 +exit_detach:
 +      i2c_detach_client(new_client);
 +exit_free:
 +      kfree(data);
-+      pcf50606_global = NULL;
 +      return err;
 +}
 +
@@ -1934,10 +1934,10 @@
 +
 +module_init(pcf50606_init);
 +module_exit(pcf50606_exit);
-Index: linux-2.6.21-moko/drivers/i2c/chips/pcf50606.h
+Index: linux-2.6.21.3-moko/drivers/i2c/chips/pcf50606.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.21-moko/drivers/i2c/chips/pcf50606.h
++++ linux-2.6.21.3-moko/drivers/i2c/chips/pcf50606.h
 @@ -0,0 +1,302 @@
 +#ifndef _PCF50606_H
 +#define _PCF50606_H
@@ -2241,10 +2241,10 @@
 +
 +#endif /* _PCF50606_H */
 +
-Index: linux-2.6.21-moko/drivers/i2c/chips/Kconfig
+Index: linux-2.6.21.3-moko/drivers/i2c/chips/Kconfig
 ===================================================================
---- linux-2.6.21-moko.orig/drivers/i2c/chips/Kconfig
-+++ linux-2.6.21-moko/drivers/i2c/chips/Kconfig
+--- linux-2.6.21.3-moko.orig/drivers/i2c/chips/Kconfig
++++ linux-2.6.21.3-moko/drivers/i2c/chips/Kconfig
 @@ -36,6 +36,17 @@
          This driver can also be built as a module.  If so, the module
          will be called eeprom.
@@ -2263,10 +2263,10 @@
  config SENSORS_PCF8574
        tristate "Philips PCF8574 and PCF8574A"
        depends on I2C && EXPERIMENTAL
-Index: linux-2.6.21-moko/drivers/i2c/chips/Makefile
+Index: linux-2.6.21.3-moko/drivers/i2c/chips/Makefile
 ===================================================================
---- linux-2.6.21-moko.orig/drivers/i2c/chips/Makefile
-+++ linux-2.6.21-moko/drivers/i2c/chips/Makefile
+--- linux-2.6.21.3-moko.orig/drivers/i2c/chips/Makefile
++++ linux-2.6.21.3-moko/drivers/i2c/chips/Makefile
 @@ -8,6 +8,7 @@
  obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
  obj-$(CONFIG_SENSORS_M41T00)  += m41t00.o
@@ -2275,10 +2275,10 @@
  obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
  obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
  obj-$(CONFIG_ISP1301_OMAP)    += isp1301_omap.o
-Index: linux-2.6.21-moko/include/linux/i2c-id.h
+Index: linux-2.6.21.3-moko/include/linux/i2c-id.h
 ===================================================================
---- linux-2.6.21-moko.orig/include/linux/i2c-id.h
-+++ linux-2.6.21-moko/include/linux/i2c-id.h
+--- linux-2.6.21.3-moko.orig/include/linux/i2c-id.h
++++ linux-2.6.21.3-moko/include/linux/i2c-id.h
 @@ -159,6 +159,7 @@
  #define I2C_DRIVERID_FSCHER 1046
  #define I2C_DRIVERID_W83L785TS 1047
@@ -2287,10 +2287,10 @@
  
  /*
   * ---- Adapter types ----------------------------------------------------
-Index: linux-2.6.21-moko/include/linux/pcf50606.h
+Index: linux-2.6.21.3-moko/include/linux/pcf50606.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.21-moko/include/linux/pcf50606.h
++++ linux-2.6.21.3-moko/include/linux/pcf50606.h
 @@ -0,0 +1,104 @@
 +#ifndef _LINUX_PCF50606_H
 +#define _LINUX_PCF50606_H




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-06-02 18:46:39 +0200 (Sat, 02 Jun 2007)
New Revision: 2134

Modified:
   trunk/src/target/kernel/patches/gta01-core.patch
Log:
fix race condition due to boot-time driver initialization order problem
i.e. what happens if UDC wants to enable fast charge before pcf50606 driver
is initialized? (Andrzej Zaborowski)


Modified: trunk/src/target/kernel/patches/gta01-core.patch
===================================================================
--- trunk/src/target/kernel/patches/gta01-core.patch    2007-06-02 16:45:33 UTC 
(rev 2133)
+++ trunk/src/target/kernel/patches/gta01-core.patch    2007-06-02 16:46:39 UTC 
(rev 2134)
@@ -1,10 +1,10 @@
 This patch adds support for the FIC GTA01 machine type to the ARM port of
 the linux kernel.
 
-Index: linux-2.6.21-moko/arch/arm/mach-s3c2410/Kconfig
+Index: linux-2.6.21.3-moko/arch/arm/mach-s3c2410/Kconfig
 ===================================================================
---- linux-2.6.21-moko.orig/arch/arm/mach-s3c2410/Kconfig
-+++ linux-2.6.21-moko/arch/arm/mach-s3c2410/Kconfig
+--- linux-2.6.21.3-moko.orig/arch/arm/mach-s3c2410/Kconfig
++++ linux-2.6.21.3-moko/arch/arm/mach-s3c2410/Kconfig
 @@ -109,5 +109,12 @@
        help
           Say Y here if you are using the Armzone QT2410
@@ -18,20 +18,20 @@
 +
  endmenu
  
-Index: linux-2.6.21-moko/arch/arm/mach-s3c2410/Makefile
+Index: linux-2.6.21.3-moko/arch/arm/mach-s3c2410/Makefile
 ===================================================================
---- linux-2.6.21-moko.orig/arch/arm/mach-s3c2410/Makefile
-+++ linux-2.6.21-moko/arch/arm/mach-s3c2410/Makefile
+--- linux-2.6.21.3-moko.orig/arch/arm/mach-s3c2410/Makefile
++++ linux-2.6.21.3-moko/arch/arm/mach-s3c2410/Makefile
 @@ -29,3 +29,4 @@
  obj-$(CONFIG_BAST_PC104_IRQ)  += bast-irq.o
  obj-$(CONFIG_MACH_VR1000)     += mach-vr1000.o usb-simtec.o
  obj-$(CONFIG_MACH_QT2410)     += mach-qt2410.o
 +obj-$(CONFIG_MACH_NEO1973_GTA01)+= mach-gta01.o
-Index: linux-2.6.21-moko/arch/arm/mach-s3c2410/mach-gta01.c
+Index: linux-2.6.21.3-moko/arch/arm/mach-s3c2410/mach-gta01.c
 ===================================================================
 --- /dev/null
-+++ linux-2.6.21-moko/arch/arm/mach-s3c2410/mach-gta01.c
-@@ -0,0 +1,753 @@
++++ linux-2.6.21.3-moko/arch/arm/mach-s3c2410/mach-gta01.c
+@@ -0,0 +1,759 @@
 +/*
 + * linux/arch/arm/mach-s3c2410/mach-gta01.c
 + *
@@ -524,6 +524,12 @@
 +
 +static void __gta01_udc_vbus_draw(struct work_struct *work)
 +{
++      /* FIXME: this is a quick fix to work around boot-time
++       * ordering problems if the s3c2410_udc is initialized
++       * before the pcf50606 driver has defined pcf50606_global */
++      if (!pcf50606_global)
++              return;
++
 +      if (gta01_udc_vbus_drawer.ma >= 500) {
 +              /* enable fast charge */
 +              printk(KERN_DEBUG "udc: enabling fast charge\n");
@@ -785,10 +791,10 @@
 +MACHINE_END
 +
 +
-Index: linux-2.6.21-moko/include/asm-arm/arch-s3c2410/gta01.h
+Index: linux-2.6.21.3-moko/include/asm-arm/arch-s3c2410/gta01.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.21-moko/include/asm-arm/arch-s3c2410/gta01.h
++++ linux-2.6.21.3-moko/include/asm-arm/arch-s3c2410/gta01.h
 @@ -0,0 +1,70 @@
 +#ifndef _GTA01_H
 +#define _GTA01_H




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-06-03 08:21:35 +0200 (Sun, 03 Jun 2007)
New Revision: 2135

Modified:
   trunk/src/target/gsm/src/gsmd/usock.c
Log:
first implementation (ugly) of operator name query


Modified: trunk/src/target/gsm/src/gsmd/usock.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/usock.c       2007-06-02 16:46:39 UTC (rev 
2134)
+++ trunk/src/target/gsm/src/gsmd/usock.c       2007-06-03 06:21:35 UTC (rev 
2135)
@@ -361,23 +361,42 @@
        return 0;
 }
 
+#define GSMD_OPER_MAXLEN       16
 static int network_oper_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
        struct gsmd_user *gu = ctx;
-       struct gsmd_signal_quality *gsq;
        struct gsmd_ucmd *ucmd;
-       char *comma;
+       char *comma, *opname;
        
-       ucmd = gsmd_ucmd_fill(sizeof(*gsq), GSMD_MSG_NETWORK,
+       ucmd = gsmd_ucmd_fill(GSMD_OPER_MAXLEN+1, GSMD_MSG_NETWORK,
                              GSMD_NETWORK_OPER_GET, 0);
        if (!ucmd)
                return -ENOMEM;
 
-       /* FIXME: implementation */
+       /* Format: <mode>[, <format>, <oper>] */
+       comma = strchr(resp, ',');
+       if (!comma)
+               goto out_err;
 
+       if (atoi(comma+1) != 0) {
+               gsmd_log(GSMD_NOTICE, "COPS format !=0 not supported yet!\n");
+               goto out_err;
+       }
+       comma = strchr(resp, ',');
+       if (!comma || *(comma+1) != '"')
+               goto out_err;
+       opname = comma+2;
+
+       memcpy(ucmd->buf, opname, strlen(opname-1));
+       ucmd->buf[strlen(opname)] = '\0';
+
        usock_cmd_enqueue(ucmd, gu);
 
        return 0;
+
+out_err:
+       talloc_free(ucmd);
+       return -EIO;
 }
 
 static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, 




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to