Re: [PATCH] rilmodem: fix register of unsolicited notify

2021-12-13 Thread Denis Kenzior

Hi Xiaovi,

On 12/13/21 2:35 AM, Xiaoyi Chen wrote:

---
  drivers/rilmodem/stk.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)



Applied, thanks.

Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: [PATCH] quectel: get devinfo

2021-12-13 Thread Denis Kenzior

Hi Sean,


What do you think about this: [0]

In attr_cb() the +10 to attr pointer I need to do better.
While looking at the code, in attr_cb() do we leak the attr string? I
can't find where it's free'd :)


No, the string is declared as const char in both attr_cb and 
at_util_parse_attr().  So it is returning a pointer to a buffer owned by GAtChat.





  static void attr_cb(gboolean ok, GAtResult *result, gpointer user_data)
  {
-   struct cb_data *cbd = user_data;
+   struct custom_cb_data *ccd = user_data;
+   struct cb_data *cbd = ccd->cbd;
ofono_devinfo_query_cb_t cb = cbd->cb;
const char *prefix = cbd->user;
struct ofono_error error;
@@ -57,21 +69,33 @@ static void attr_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
return;
}
  
+	if (ccd->vendor == OFONO_VENDOR_QUECTEL_SERIAL &&

+   (!strcmp(prefix, "+CGMI:") ||
+!strcmp(prefix, "+CGMR:"))) {
+   if (!strncmp("Revision: ", attr, 10)) {
+   cb(, attr+10, cbd->data);
+   return;


https://people.gnome.org/~ryanl/glib-docs/glib-String-Utility-Functions.html#g-str-has-prefix


+   }
+   }
+
cb(, attr, cbd->data);
  }
  





@@ -111,15 +141,18 @@ static void at_query_revision(struct ofono_devinfo *info,
  static void at_query_serial(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data)
  {
-   struct cb_data *cbd = cb_data_new(cb, data);
-   GAtChat *chat = ofono_devinfo_get_data(info);
+   struct custom_cb_data *ccd = g_new0(struct custom_cb_data, 1);
+   struct dev_data *dev = ofono_devinfo_get_data(info);
+   ccd->cbd = cb_data_new(cb, data);
+   ccd->vendor = dev->vendor;


Why not just put everything you need from cb_data into your custom data object 
instead of trying to allocate cb_data.


  
-	cbd->user = "+CGSN:";

+   ccd->cbd->user = "+CGSN:";
  
-	if (g_at_chat_send(chat, "AT+CGSN", NULL, attr_cb, cbd, g_free) > 0)

+   if (g_at_chat_send(dev->chat, "AT+CGSN", NULL, attr_cb, ccd, g_free) > 
0)
return;
  
-	g_free(cbd);

+   g_free(ccd->cbd);
+   g_free(ccd);
  
  	CALLBACK_WITH_FAILURE(cb, NULL, data);

  }





@@ -146,11 +184,11 @@ static int at_devinfo_probe(struct ofono_devinfo *info, 
unsigned int vendor,
  
  static void at_devinfo_remove(struct ofono_devinfo *info)

  {
-   GAtChat *chat = ofono_devinfo_get_data(info);
+   struct dev_data *dev = ofono_devinfo_get_data(info);
  
-	ofono_devinfo_set_data(info, NULL);

+   g_at_chat_unref(dev->chat);


free dev?
  
-	g_at_chat_unref(chat);

+   ofono_devinfo_set_data(info, NULL);
  }
  
  static const struct ofono_devinfo_driver driver = {




Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[PATCH] rilmodem: fix register of unsolicited notify

2021-12-13 Thread Xiaoyi Chen
---
 drivers/rilmodem/stk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rilmodem/stk.c b/drivers/rilmodem/stk.c
index 47b469d2..0bfb7c05 100644
--- a/drivers/rilmodem/stk.c
+++ b/drivers/rilmodem/stk.c
@@ -214,13 +214,13 @@ static int ril_stk_probe(struct ofono_stk *stk, unsigned 
int vendor,
 
ofono_stk_set_data(stk, data);
 
-   g_ril_register(ril, RIL_UNSOL_STK_PROACTIVE_COMMAND,
+   g_ril_register(data->ril, RIL_UNSOL_STK_PROACTIVE_COMMAND,
ril_stk_proactive_cmd_notify, stk);
 
-   g_ril_register(ril, RIL_UNSOL_STK_SESSION_END,
+   g_ril_register(data->ril, RIL_UNSOL_STK_SESSION_END,
ril_stk_session_end_notify, stk);
 
-   g_ril_register(ril, RIL_UNSOL_STK_EVENT_NOTIFY,
+   g_ril_register(data->ril, RIL_UNSOL_STK_EVENT_NOTIFY,
ril_stk_event_notify, stk);
 
g_ril_send(data->ril, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, NULL,
-- 
2.17.1
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org