* [PATCH v2 02/23] qmi: lookup shared family directly by type
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 03/23] core: allow multiple args in atom constructors Denis Kenzior
` (21 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Since it is currently no longer possible to create dedicated clients for
a given service type, use the service type as the key to the family_list
hashtable. For QMUX, this allows the service family to be looked up
directly instead of iterating over the entire hash table. The hash
table entry at key=service_type will always point to the shared service
family.
---
drivers/qmimodem/qmi.c | 61 +++++++++---------------------------------
1 file changed, 13 insertions(+), 48 deletions(-)
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index dfcf46a6e35e..1b3fa34f685c 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -330,21 +330,6 @@ static bool __notify_compare(const void *data, const void *user_data)
notify->service_handle == details->service_handle;
}
-struct service_find_by_type_data {
- unsigned int type;
- struct service_family *found_family;
-};
-
-static void __family_find_by_type(const void *key, void *value,
- void *user_data)
-{
- struct service_family *family = value;
- struct service_find_by_type_data *data = user_data;
-
- if (family->info.service_type == data->type)
- data->found_family = family;
-}
-
static const char *__service_type_to_string(uint8_t type)
{
switch (type) {
@@ -1403,7 +1388,6 @@ static struct service_family *service_family_ref(struct service_family *family)
static void service_family_unref(struct service_family *family)
{
struct qmi_device *device;
- unsigned int hash_id;
if (--family->ref_count)
return;
@@ -1412,9 +1396,15 @@ static void service_family_unref(struct service_family *family)
if (!device)
goto done;
- hash_id = family_list_create_hash(family->info.service_type,
+ if (family->client_id) {
+ unsigned int hash_id =
+ family_list_create_hash(family->info.service_type,
family->client_id);
- l_hashmap_remove(device->family_list, L_UINT_TO_PTR(hash_id));
+ l_hashmap_remove(device->family_list, L_UINT_TO_PTR(hash_id));
+ }
+
+ l_hashmap_remove(device->family_list,
+ L_UINT_TO_PTR(family->info.service_type));
if (device->ops->client_release)
device->ops->client_release(device, family->info.service_type,
@@ -1799,7 +1789,6 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
struct qmi_device_qmux *qmux =
l_container_of(device, struct qmi_device_qmux, super);
struct service_family *family = NULL;
- struct service_family *old_family = NULL;
struct qmi_service_info info;
const struct qmi_result_code *result_code;
const struct qmi_client_id *client_id;
@@ -1829,16 +1818,13 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
info.minor = data->minor;
family = service_family_create(device, &info, client_id->client);
-
+ family = service_family_ref(family);
hash_id = family_list_create_hash(family->info.service_type,
family->client_id);
- l_hashmap_replace(device->family_list, L_UINT_TO_PTR(hash_id),
- family, (void **) &old_family);
-
- if (old_family)
- family_destroy(old_family);
-
- family = service_family_ref(family);
+ l_hashmap_insert(device->family_list, L_UINT_TO_PTR(hash_id), family);
+ l_hashmap_insert(device->family_list,
+ L_UINT_TO_PTR(family->info.service_type),
+ family);
done:
service_create_shared_pending_reply(qmux, data->type, family);
if (family)
@@ -2636,28 +2622,7 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type,
if (type == QMI_SERVICE_CONTROL)
return false;
- /*
- * First check to see if the bare type is in the hashmap. If it is not
- * the family might exist already, but have the client id included in
- * the hash id.
- */
family = l_hashmap_lookup(device->family_list, L_UINT_TO_PTR(type));
-
- if (!family) {
- struct service_find_by_type_data find_data;
-
- /*
- * There is no way to find in an l_hashmap using a custom
- * function. Instead we use a temporary struct to store the
- * found service family.
- */
- find_data.type = type;
- find_data.found_family = NULL;
- l_hashmap_foreach(device->family_list, __family_find_by_type,
- &find_data);
- family = find_data.found_family;
- }
-
if (!family) {
const struct qmi_service_info *info;
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 03/23] core: allow multiple args in atom constructors
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 02/23] qmi: lookup shared family directly by type Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 04/23] unit: Update unit tests to the new API Denis Kenzior
` (20 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
It would be useful to send multiple arguments to atom probe() functions
without having to define / create an intermediate structure. To that
end, add the ability to send multiple arguments to all atom
constructors. To keep backwards compatibility, the probe() method is
invoked with a single void * argument.
---
include/audio-settings.h | 6 +++++-
include/call-barring.h | 6 +++++-
include/call-forwarding.h | 6 +++++-
include/call-meter.h | 6 +++++-
include/call-settings.h | 6 +++++-
include/call-volume.h | 6 +++++-
include/cbs.h | 5 ++++-
include/ctm.h | 5 ++++-
include/devinfo.h | 6 +++++-
include/gnss.h | 6 +++++-
include/gprs-context.h | 6 +++++-
include/gprs.h | 6 +++++-
include/handsfree.h | 6 +++++-
include/ims.h | 5 ++++-
include/location-reporting.h | 6 +++++-
include/lte.h | 5 ++++-
include/netmon.h | 6 +++++-
include/netreg.h | 7 +++++--
include/phonebook.h | 6 +++++-
include/radio-settings.h | 6 +++++-
include/sim.h | 5 ++++-
include/siri.h | 6 +++++-
include/sms.h | 5 ++++-
include/stk.h | 5 ++++-
include/ussd.h | 6 +++++-
include/voicecall.h | 6 +++++-
src/ofono.h | 16 +++++++++++++---
27 files changed, 136 insertions(+), 30 deletions(-)
diff --git a/include/audio-settings.h b/include/audio-settings.h
index 797f6e3780ec..452d7e73632d 100644
--- a/include/audio-settings.h
+++ b/include/audio-settings.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_audio_settings;
@@ -19,6 +21,8 @@ struct ofono_audio_settings;
struct ofono_audio_settings_driver {
int (*probe)(struct ofono_audio_settings *as,
unsigned int vendor, void *data);
+ int (*probev)(struct ofono_audio_settings *as,
+ unsigned int vendor, va_list args);
void (*remove)(struct ofono_audio_settings *as);
};
@@ -30,7 +34,7 @@ void ofono_audio_settings_mode_notify(struct ofono_audio_settings *as,
struct ofono_audio_settings *ofono_audio_settings_create(
struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_audio_settings_register(struct ofono_audio_settings *as);
void ofono_audio_settings_remove(struct ofono_audio_settings *as);
diff --git a/include/call-barring.h b/include/call-barring.h
index 05df4270543b..99e2764e64da 100644
--- a/include/call-barring.h
+++ b/include/call-barring.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_call_barring;
@@ -24,6 +26,8 @@ typedef void (*ofono_call_barring_query_cb_t)(const struct ofono_error *error,
struct ofono_call_barring_driver {
int (*probe)(struct ofono_call_barring *cb, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_call_barring *cb, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_call_barring *cb);
void (*set)(struct ofono_call_barring *barr, const char *lock,
int enable, const char *passwd, int cls,
@@ -38,7 +42,7 @@ struct ofono_call_barring_driver {
struct ofono_call_barring *ofono_call_barring_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data);
+ ...);
void ofono_call_barring_register(struct ofono_call_barring *cb);
void ofono_call_barring_remove(struct ofono_call_barring *cb);
diff --git a/include/call-forwarding.h b/include/call-forwarding.h
index b4ad0a206788..2eb2f1817b8d 100644
--- a/include/call-forwarding.h
+++ b/include/call-forwarding.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_call_forwarding;
@@ -34,6 +36,8 @@ typedef void (*ofono_call_forwarding_query_cb_t)(
struct ofono_call_forwarding_driver {
int (*probe)(struct ofono_call_forwarding *cf, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_call_forwarding *cf, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_call_forwarding *cf);
void (*activation)(struct ofono_call_forwarding *cf,
int type, int cls,
@@ -56,7 +60,7 @@ struct ofono_call_forwarding_driver {
struct ofono_call_forwarding *ofono_call_forwarding_create(
struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_call_forwarding_register(struct ofono_call_forwarding *cf);
void ofono_call_forwarding_remove(struct ofono_call_forwarding *cf);
diff --git a/include/call-meter.h b/include/call-meter.h
index feaef17ed5f1..9a00104a2ede 100644
--- a/include/call-meter.h
+++ b/include/call-meter.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_call_meter;
@@ -30,6 +32,8 @@ typedef void(*ofono_call_meter_set_cb_t)(const struct ofono_error *error,
struct ofono_call_meter_driver {
int (*probe)(struct ofono_call_meter *cm, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_call_meter *cm, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_call_meter *cm);
void (*call_meter_query)(struct ofono_call_meter *cm,
ofono_call_meter_query_cb_t cb, void *data);
@@ -52,7 +56,7 @@ struct ofono_call_meter_driver {
struct ofono_call_meter *ofono_call_meter_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data);
+ ...);
void ofono_call_meter_register(struct ofono_call_meter *cm);
void ofono_call_meter_remove(struct ofono_call_meter *cm);
diff --git a/include/call-settings.h b/include/call-settings.h
index 854cc96afa97..ced1047fd3d2 100644
--- a/include/call-settings.h
+++ b/include/call-settings.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_call_settings;
@@ -28,6 +30,8 @@ typedef void (*ofono_call_settings_clir_cb_t)(const struct ofono_error *error,
struct ofono_call_settings_driver {
int (*probe)(struct ofono_call_settings *cs, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_call_settings *cs, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_call_settings *cs);
void (*clip_query)(struct ofono_call_settings *cs,
ofono_call_settings_status_cb_t cb, void *data);
@@ -52,7 +56,7 @@ struct ofono_call_settings_driver {
struct ofono_call_settings *ofono_call_settings_create(
struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_call_settings_register(struct ofono_call_settings *cs);
void ofono_call_settings_remove(struct ofono_call_settings *cs);
diff --git a/include/call-volume.h b/include/call-volume.h
index bf3606353cff..90629b25cc1f 100644
--- a/include/call-volume.h
+++ b/include/call-volume.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
#include <ofono/dbus.h>
@@ -23,6 +25,8 @@ typedef void (*ofono_call_volume_cb_t)(const struct ofono_error *error,
struct ofono_call_volume_driver {
int (*probe)(struct ofono_call_volume *cv, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_call_volume *cv, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_call_volume *cv);
void (*speaker_volume)(struct ofono_call_volume *cv,
unsigned char percent,
@@ -41,7 +45,7 @@ void ofono_call_volume_set_microphone_volume(struct ofono_call_volume *cv,
void ofono_call_volume_set_muted(struct ofono_call_volume *cv, int muted);
struct ofono_call_volume *ofono_call_volume_create(struct ofono_modem *modem,
- unsigned int vendor, const char *driver, void *data);
+ unsigned int vendor, const char *driver, ...);
void ofono_call_volume_register(struct ofono_call_volume *cv);
void ofono_call_volume_remove(struct ofono_call_volume *cv);
diff --git a/include/cbs.h b/include/cbs.h
index 7ec4b60afeda..9d3367b7b24f 100644
--- a/include/cbs.h
+++ b/include/cbs.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_cbs;
@@ -21,6 +23,7 @@ typedef void (*ofono_cbs_set_cb_t)(const struct ofono_error *error,
struct ofono_cbs_driver {
int (*probe)(struct ofono_cbs *cbs, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_cbs *cbs, unsigned int vendor, va_list args);
void (*remove)(struct ofono_cbs *cbs);
void (*set_topics)(struct ofono_cbs *cbs, const char *topics,
ofono_cbs_set_cb_t cb, void *data);
@@ -32,7 +35,7 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned char *pdu, int len);
struct ofono_cbs *ofono_cbs_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_cbs_register(struct ofono_cbs *cbs);
void ofono_cbs_remove(struct ofono_cbs *cbs);
diff --git a/include/ctm.h b/include/ctm.h
index 5d600a500f9e..315fa5d562f3 100644
--- a/include/ctm.h
+++ b/include/ctm.h
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_ctm;
@@ -24,6 +26,7 @@ typedef void (*ofono_ctm_query_cb_t)(const struct ofono_error *error,
struct ofono_ctm_driver {
int (*probe)(struct ofono_ctm *ctm, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_ctm *ctm, unsigned int vendor, va_list args);
void (*remove)(struct ofono_ctm *ctm);
void (*query_tty)(struct ofono_ctm *ctm,
ofono_ctm_query_cb_t cb, void *data);
@@ -33,7 +36,7 @@ struct ofono_ctm_driver {
struct ofono_ctm *ofono_ctm_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_ctm_register(struct ofono_ctm *ctm);
void ofono_ctm_remove(struct ofono_ctm *ctm);
diff --git a/include/devinfo.h b/include/devinfo.h
index 59a1bd21ecdb..ac553e959443 100644
--- a/include/devinfo.h
+++ b/include/devinfo.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_devinfo;
@@ -22,6 +24,8 @@ typedef void (*ofono_devinfo_query_cb_t)(const struct ofono_error *error,
struct ofono_devinfo_driver {
int (*probe)(struct ofono_devinfo *info, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_devinfo *info, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_devinfo *info);
void (*query_manufacturer)(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data);
@@ -38,7 +42,7 @@ struct ofono_devinfo_driver {
struct ofono_devinfo *ofono_devinfo_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data);
+ ...);
void ofono_devinfo_register(struct ofono_devinfo *info);
void ofono_devinfo_remove(struct ofono_devinfo *info);
diff --git a/include/gnss.h b/include/gnss.h
index 700fc2737a6d..dd1b79246f72 100644
--- a/include/gnss.h
+++ b/include/gnss.h
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_gnss;
@@ -21,6 +23,8 @@ typedef void (*ofono_gnss_cb_t)(const struct ofono_error *error, void *data);
struct ofono_gnss_driver {
int (*probe)(struct ofono_gnss *gnss, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_gnss *gnss, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_gnss *gnss);
void (*send_element)(struct ofono_gnss *gnss,
const char *xml,
@@ -36,7 +40,7 @@ void ofono_gnss_notify_posr_reset(struct ofono_gnss *gnss);
struct ofono_gnss *ofono_gnss_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_gnss_register(struct ofono_gnss *gnss);
void ofono_gnss_remove(struct ofono_gnss *gnss);
diff --git a/include/gprs-context.h b/include/gprs-context.h
index dab00191d3f6..2bc9dd166787 100644
--- a/include/gprs-context.h
+++ b/include/gprs-context.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_gprs_context;
@@ -42,6 +44,8 @@ typedef void (*ofono_gprs_context_cb_t)(const struct ofono_error *error,
struct ofono_gprs_context_driver {
int (*probe)(struct ofono_gprs_context *gc, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_gprs_context *gc, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_gprs_context *gc);
void (*activate_primary)(struct ofono_gprs_context *gc,
const struct ofono_gprs_primary_context *ctx,
@@ -61,7 +65,7 @@ void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc,
struct ofono_gprs_context *ofono_gprs_context_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_gprs_context_remove(struct ofono_gprs_context *gc);
void ofono_gprs_context_set_data(struct ofono_gprs_context *gc, void *data);
diff --git a/include/gprs.h b/include/gprs.h
index f4706c5cdbd7..62bf05baf30b 100644
--- a/include/gprs.h
+++ b/include/gprs.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_gprs;
@@ -25,6 +27,8 @@ typedef void (*ofono_gprs_cb_t)(const struct ofono_error *error, void *data);
struct ofono_gprs_driver {
int (*probe)(struct ofono_gprs *gprs, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_gprs *gprs, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_gprs *gprs);
void (*set_attached)(struct ofono_gprs *gprs, int attached,
ofono_gprs_cb_t cb, void *data);
@@ -52,7 +56,7 @@ struct ofono_modem *ofono_gprs_get_modem(struct ofono_gprs *gprs);
struct ofono_gprs *ofono_gprs_create(struct ofono_modem *modem,
unsigned int vendor, const char *driver,
- void *data);
+ ...);
void ofono_gprs_register(struct ofono_gprs *gprs);
void ofono_gprs_remove(struct ofono_gprs *gprs);
diff --git a/include/handsfree.h b/include/handsfree.h
index 326d79c33c9e..43fe572693f6 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_handsfree;
@@ -30,6 +32,8 @@ typedef void (*ofono_handsfree_cnum_query_cb_t)(const struct ofono_error *error,
struct ofono_handsfree_driver {
int (*probe)(struct ofono_handsfree *hf, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_handsfree *hf, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_handsfree *hf);
void (*cnum_query)(struct ofono_handsfree *hf,
ofono_handsfree_cnum_query_cb_t cb, void *data);
@@ -66,7 +70,7 @@ void ofono_handsfree_battchg_notify(struct ofono_handsfree *hf,
unsigned char level);
struct ofono_handsfree *ofono_handsfree_create(struct ofono_modem *modem,
- unsigned int vendor, const char *driver, void *data);
+ unsigned int vendor, const char *driver, ...);
void ofono_handsfree_register(struct ofono_handsfree *hf);
void ofono_handsfree_remove(struct ofono_handsfree *hf);
diff --git a/include/ims.h b/include/ims.h
index 737532b17500..c394d5160c26 100644
--- a/include/ims.h
+++ b/include/ims.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_ims;
@@ -24,6 +26,7 @@ typedef void (*ofono_ims_status_cb_t)(const struct ofono_error *error,
struct ofono_ims_driver {
int (*probe)(struct ofono_ims *ims, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_ims *ims, unsigned int vendor, va_list args);
void (*remove)(struct ofono_ims *ims);
void (*ims_register)(struct ofono_ims *ims,
ofono_ims_register_cb_t cb, void *data);
@@ -38,7 +41,7 @@ void ofono_ims_status_notify(struct ofono_ims *ims, int reg_info,
struct ofono_ims *ofono_ims_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_ims_register(struct ofono_ims *ims);
void ofono_ims_remove(struct ofono_ims *ims);
diff --git a/include/location-reporting.h b/include/location-reporting.h
index 38003a950005..7faf0ba3c485 100644
--- a/include/location-reporting.h
+++ b/include/location-reporting.h
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_location_reporting;
@@ -32,6 +34,8 @@ struct ofono_location_reporting_driver {
enum ofono_location_reporting_type type;
int (*probe)(struct ofono_location_reporting *lr, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_location_reporting *lr, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_location_reporting *lr);
void (*enable)(struct ofono_location_reporting *lr,
ofono_location_reporting_enable_cb_t cb, void *data);
@@ -42,7 +46,7 @@ struct ofono_location_reporting_driver {
struct ofono_location_reporting *ofono_location_reporting_create(
struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_location_reporting_register(struct ofono_location_reporting *lr);
void ofono_location_reporting_remove(struct ofono_location_reporting *lr);
diff --git a/include/lte.h b/include/lte.h
index 378b8faf5d43..3f8dbd535e69 100644
--- a/include/lte.h
+++ b/include/lte.h
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_lte;
@@ -29,6 +31,7 @@ typedef void (*ofono_lte_cb_t)(const struct ofono_error *error, void *data);
struct ofono_lte_driver {
int (*probe)(struct ofono_lte *lte, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_lte *lte, unsigned int vendor, va_list args);
void (*remove)(struct ofono_lte *lte);
void (*set_default_attach_info)(const struct ofono_lte *lte,
const struct ofono_lte_default_attach_info *info,
@@ -37,7 +40,7 @@ struct ofono_lte_driver {
struct ofono_lte *ofono_lte_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_lte_register(struct ofono_lte *lte);
diff --git a/include/netmon.h b/include/netmon.h
index 85d25706f06a..d1eef952314e 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_netmon;
@@ -21,6 +23,8 @@ typedef void (*ofono_netmon_cb_t)(const struct ofono_error *error, void *data);
struct ofono_netmon_driver {
int (*probe)(struct ofono_netmon *netmon, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_netmon *netmon, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_netmon *netmon);
void (*request_update)(struct ofono_netmon *netmon,
ofono_netmon_cb_t cb, void *data);
@@ -80,7 +84,7 @@ void ofono_netmon_serving_cell_notify(struct ofono_netmon *netmon,
struct ofono_netmon *ofono_netmon_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_netmon_register(struct ofono_netmon *netmon);
diff --git a/include/netreg.h b/include/netreg.h
index e70283bf6bd5..48a13e161fea 100644
--- a/include/netreg.h
+++ b/include/netreg.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_netreg;
@@ -57,6 +59,8 @@ typedef void (*ofono_netreg_strength_cb_t)(const struct ofono_error *error,
struct ofono_netreg_driver {
int (*probe)(struct ofono_netreg *netreg, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_netreg *netreg, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_netreg *netreg);
void (*registration_status)(struct ofono_netreg *netreg,
ofono_netreg_status_cb_t cb, void *data);
@@ -81,8 +85,7 @@ void ofono_netreg_time_notify(struct ofono_netreg *netreg,
struct ofono_netreg *ofono_netreg_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver,
- void *data);
+ const char *driver, ...);
void ofono_netreg_register(struct ofono_netreg *netreg);
void ofono_netreg_remove(struct ofono_netreg *netreg);
diff --git a/include/phonebook.h b/include/phonebook.h
index 2944e3a0d836..2c895fa9cf13 100644
--- a/include/phonebook.h
+++ b/include/phonebook.h
@@ -26,6 +26,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_phonebook;
@@ -39,6 +41,8 @@ typedef void (*ofono_phonebook_cb_t)(const struct ofono_error *error,
struct ofono_phonebook_driver {
int (*probe)(struct ofono_phonebook *pb, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_phonebook *pb, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_phonebook *pb);
void (*export_entries)(struct ofono_phonebook *pb, const char *storage,
ofono_phonebook_cb_t cb, void *data);
@@ -55,7 +59,7 @@ void ofono_phonebook_entry(struct ofono_phonebook *pb, int index,
struct ofono_phonebook *ofono_phonebook_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data);
+ ...);
void ofono_phonebook_register(struct ofono_phonebook *pb);
void ofono_phonebook_remove(struct ofono_phonebook *pb);
diff --git a/include/radio-settings.h b/include/radio-settings.h
index c424d374bb57..7dcccf81d226 100644
--- a/include/radio-settings.h
+++ b/include/radio-settings.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
enum ofono_radio_access_mode {
@@ -73,6 +75,8 @@ typedef void (*ofono_radio_settings_available_rats_query_cb_t)(
struct ofono_radio_settings_driver {
int (*probe)(struct ofono_radio_settings *rs, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_radio_settings *rs, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_radio_settings *rs);
void (*query_rat_mode)(struct ofono_radio_settings *rs,
ofono_radio_settings_rat_mode_query_cb_t cb,
@@ -103,7 +107,7 @@ struct ofono_radio_settings_driver {
struct ofono_radio_settings *ofono_radio_settings_create(
struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_radio_settings_register(struct ofono_radio_settings *rs);
void ofono_radio_settings_remove(struct ofono_radio_settings *rs);
diff --git a/include/sim.h b/include/sim.h
index 326a6fe09709..c362cc0ecb62 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_sim;
@@ -124,6 +126,7 @@ typedef void (*ofono_sim_set_active_card_slot_cb_t)(
struct ofono_sim_driver {
int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_sim *sim, unsigned int vendor, va_list args);
void (*remove)(struct ofono_sim *sim);
void (*read_file_info)(struct ofono_sim *sim, int fileid,
const unsigned char *path, unsigned int path_len,
@@ -200,7 +203,7 @@ struct ofono_sim_driver {
struct ofono_sim *ofono_sim_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_sim_register(struct ofono_sim *sim);
void ofono_sim_remove(struct ofono_sim *sim);
diff --git a/include/siri.h b/include/siri.h
index be09c49236a4..0a9702b2037a 100644
--- a/include/siri.h
+++ b/include/siri.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_siri;
@@ -21,6 +23,8 @@ typedef void (*ofono_siri_cb_t)(const struct ofono_error *error,
struct ofono_siri_driver {
int (*probe)(struct ofono_siri *siri, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_siri *siri, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_siri *siri);
void (*set_eyes_free_mode) (struct ofono_siri *siri, ofono_siri_cb_t cb,
unsigned int val);
@@ -30,7 +34,7 @@ void ofono_siri_set_status(struct ofono_siri *siri, int value);
struct ofono_siri *ofono_siri_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_siri_register(struct ofono_siri *siri);
void ofono_siri_remove(struct ofono_siri *siri);
diff --git a/include/sms.h b/include/sms.h
index 21ac6a3a3d35..d843ae6ae122 100644
--- a/include/sms.h
+++ b/include/sms.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_sms;
@@ -30,6 +32,7 @@ typedef void (*ofono_sms_bearer_query_cb_t)(const struct ofono_error *error,
struct ofono_sms_driver {
int (*probe)(struct ofono_sms *sms, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_sms *sms, unsigned int vendor, va_list args);
void (*remove)(struct ofono_sms *sms);
void (*sca_query)(struct ofono_sms *sms, ofono_sms_sca_query_cb_t cb,
void *data);
@@ -52,7 +55,7 @@ void ofono_sms_status_notify(struct ofono_sms *sms, const unsigned char *pdu,
struct ofono_sms *ofono_sms_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_sms_register(struct ofono_sms *sms);
void ofono_sms_remove(struct ofono_sms *sms);
diff --git a/include/stk.h b/include/stk.h
index 93311d564223..8575b2819b4a 100644
--- a/include/stk.h
+++ b/include/stk.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_stk;
@@ -25,6 +27,7 @@ typedef void (*ofono_stk_generic_cb_t)(const struct ofono_error *error,
struct ofono_stk_driver {
int (*probe)(struct ofono_stk *stk, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_stk *stk, unsigned int vendor, va_list args);
void (*remove)(struct ofono_stk *stk);
void (*envelope)(struct ofono_stk *stk,
int length, const unsigned char *command,
@@ -37,7 +40,7 @@ struct ofono_stk_driver {
struct ofono_stk *ofono_stk_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_stk_register(struct ofono_stk *stk);
void ofono_stk_remove(struct ofono_stk *stk);
diff --git a/include/ussd.h b/include/ussd.h
index 0b4895a82d52..04a91e8483b7 100644
--- a/include/ussd.h
+++ b/include/ussd.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
/* 3GPP TS 27.007 section 7.15, values for <m> */
@@ -30,6 +32,8 @@ typedef void (*ofono_ussd_cb_t)(const struct ofono_error *error, void *data);
struct ofono_ussd_driver {
int (*probe)(struct ofono_ussd *ussd, unsigned int vendor, void *data);
+ int (*probev)(struct ofono_ussd *ussd, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_ussd *ussd);
void (*request)(struct ofono_ussd *ussd, int dcs,
const unsigned char *pdu, int len,
@@ -43,7 +47,7 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs,
struct ofono_ussd *ofono_ussd_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_ussd_register(struct ofono_ussd *ussd);
void ofono_ussd_remove(struct ofono_ussd *ussd);
diff --git a/include/voicecall.h b/include/voicecall.h
index 50480b5ee015..345e52b15a0e 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
#include <ofono/types.h>
struct ofono_modem;
@@ -29,6 +31,8 @@ typedef void (*ofono_voicecall_cb_t)(const struct ofono_error *error,
struct ofono_voicecall_driver {
int (*probe)(struct ofono_voicecall *vc, unsigned int vendor,
void *data);
+ int (*probev)(struct ofono_voicecall *vc, unsigned int vendor,
+ va_list args);
void (*remove)(struct ofono_voicecall *vc);
/* According to 22.030 the dial is expected to do the following:
@@ -149,7 +153,7 @@ struct ofono_modem *ofono_voicecall_get_modem(struct ofono_voicecall *vc);
struct ofono_voicecall *ofono_voicecall_create(struct ofono_modem *modem,
unsigned int vendor,
- const char *driver, void *data);
+ const char *driver, ...);
void ofono_voicecall_register(struct ofono_voicecall *vc);
void ofono_voicecall_remove(struct ofono_voicecall *vc);
diff --git a/src/ofono.h b/src/ofono.h
index cb4eae81db1a..c6fa16f2dc01 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: GPL-2.0-only
*/
+#include <stdarg.h>
#include <glib.h>
#include <ell/ell.h>
@@ -231,15 +232,17 @@ extern struct ofono_driver_desc __stop___ ## type[]; \
struct ofono_ ## type *ofono_ ## type ##_create( \
struct ofono_modem *modem, \
unsigned int vendor, const char *driver,\
- void *data) \
+ ...) \
{ \
const struct ofono_ ## type ## _driver *drv = \
__ofono_driver_builtin_find(driver, \
__start___ ## type, \
__stop___ ## type); \
+ va_list args; \
struct ofono_ ## type *atom; \
+ int r; \
\
- if (!drv || !drv->probe) \
+ if (!drv || (!drv->probe && !drv->probev)) \
return NULL; \
\
atom = g_new0(struct ofono_ ##type, 1); \
@@ -247,7 +250,14 @@ struct ofono_ ## type *ofono_ ## type ##_create( \
type ##_remove, atom); \
__VA_ARGS__ \
\
- if (drv->probe(atom, vendor, data) < 0) { \
+ va_start(args, driver); \
+ if (drv->probev) \
+ r = drv->probev(atom, vendor, args); \
+ else \
+ r = drv->probe(atom, vendor, va_arg(args, void *)); \
+ va_end(args); \
+ \
+ if (r < 0) { \
ofono_ ## type ##_remove(atom); \
return NULL; \
} \
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 04/23] unit: Update unit tests to the new API
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 02/23] qmi: lookup shared family directly by type Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 03/23] core: allow multiple args in atom constructors Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 05/23] core: Support register on probe flag Denis Kenzior
` (19 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
unit/test-rilmodem-cb.c | 9 +++++++--
unit/test-rilmodem-cs.c | 9 +++++++--
unit/test-rilmodem-sms.c | 9 +++++++--
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/unit/test-rilmodem-cb.c b/unit/test-rilmodem-cb.c
index 75e7e02076f6..984ea4efc64e 100644
--- a/unit/test-rilmodem-cb.c
+++ b/unit/test-rilmodem-cb.c
@@ -407,11 +407,16 @@ extern struct ofono_driver_desc __start___call_barring[];
struct ofono_call_barring *ofono_call_barring_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data)
+ ...)
{
- struct rilmodem_cb_data *rsd = data;
+ struct rilmodem_cb_data *rsd;
struct ofono_call_barring *cb = g_new0(struct ofono_call_barring, 1);
int retval;
+ va_list args;
+
+ va_start(args, driver);
+ rsd = va_arg(args, void *);
+ va_end(args);
cbdriver = __start___call_barring[0].driver;
diff --git a/unit/test-rilmodem-cs.c b/unit/test-rilmodem-cs.c
index 414ded61022e..8c65fb1f6bb4 100644
--- a/unit/test-rilmodem-cs.c
+++ b/unit/test-rilmodem-cs.c
@@ -383,11 +383,16 @@ extern struct ofono_driver_desc __start___call_settings[];
struct ofono_call_settings *ofono_call_settings_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data)
+ ...)
{
- struct rilmodem_cs_data *rcd = data;
+ struct rilmodem_cs_data *rcd;
struct ofono_call_settings *cs = g_new0(struct ofono_call_settings, 1);
int retval;
+ va_list args;
+
+ va_start(args, driver);
+ rcd = va_arg(args, void *);
+ va_end(args);
csdriver = __start___call_settings[0].driver;
diff --git a/unit/test-rilmodem-sms.c b/unit/test-rilmodem-sms.c
index 347922c309b6..8d85d23ce92a 100644
--- a/unit/test-rilmodem-sms.c
+++ b/unit/test-rilmodem-sms.c
@@ -414,11 +414,16 @@ extern struct ofono_driver_desc __start___sms[];
struct ofono_sms *ofono_sms_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver,
- void *data)
+ ...)
{
- struct rilmodem_sms_data *rsd = data;
+ struct rilmodem_sms_data *rsd;
struct ofono_sms *sms = g_new0(struct ofono_sms, 1);
int retval;
+ va_list args;
+
+ va_start(args, driver);
+ rsd = va_arg(args, void *);
+ va_end(args);
smsdriver = __start___sms[0].driver;
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 05/23] core: Support register on probe flag
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (2 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 04/23] unit: Update unit tests to the new API Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 06/23] qmi: introduce qmi_service_clone Denis Kenzior
` (18 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Some atom drivers have no meaningful initialization to perform after
probe but prior to calling ofono_foo_atom_register(). Such atom drivers
are forced to use l_idle or g_timeout_add in order to invoke
ofono_foo_atom_register() outside of the probe() method. Make this
easier by introducing a flag that will tell the core to call
ofono_foo_atom_register() automatically.
One exception is ofono_gprs_context drivers which have not had a
ofono_gprs_context_register() API. Introduce such an API as a no-op for
now.
---
drivers/atmodem/gprs-context.c | 1 +
drivers/gemaltomodem/gprs-context.c | 1 +
drivers/hsomodem/gprs-context.c | 1 +
drivers/huaweimodem/gprs-context.c | 1 +
drivers/iceramodem/gprs-context.c | 1 +
drivers/ifxmodem/gprs-context.c | 1 +
drivers/isimodem/gprs-context.c | 1 +
drivers/mbimmodem/gprs-context.c | 1 +
drivers/mbmmodem/gprs-context.c | 1 +
drivers/qmimodem/gprs-context.c | 1 +
drivers/rilmodem/gprs-context.c | 1 +
drivers/stemodem/gprs-context.c | 1 +
drivers/swmodem/gprs-context.c | 1 +
drivers/ubloxmodem/gprs-context.c | 1 +
include/audio-settings.h | 1 +
include/call-barring.h | 1 +
include/call-forwarding.h | 1 +
include/call-meter.h | 1 +
include/call-settings.h | 1 +
include/call-volume.h | 1 +
include/cbs.h | 1 +
include/ctm.h | 1 +
include/devinfo.h | 1 +
include/gnss.h | 1 +
include/gprs-context.h | 1 +
include/gprs.h | 1 +
include/handsfree.h | 1 +
include/ims.h | 1 +
include/location-reporting.h | 1 +
include/lte.h | 1 +
include/modem.h | 2 ++
include/netmon.h | 1 +
include/netreg.h | 1 +
include/phonebook.h | 1 +
include/radio-settings.h | 1 +
include/sim.h | 1 +
include/siri.h | 1 +
include/sms.h | 1 +
include/stk.h | 1 +
include/ussd.h | 1 +
include/voicecall.h | 1 +
src/gprs.c | 4 ++++
src/ofono.h | 5 +++++
43 files changed, 51 insertions(+)
diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index 5cca26f57ccb..da63fa1c72f3 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -495,6 +495,7 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = at_gprs_context_probe,
.remove = at_gprs_context_remove,
.activate_primary = at_gprs_activate_primary,
diff --git a/drivers/gemaltomodem/gprs-context.c b/drivers/gemaltomodem/gprs-context.c
index 34c044207274..f60fd4282a31 100644
--- a/drivers/gemaltomodem/gprs-context.c
+++ b/drivers/gemaltomodem/gprs-context.c
@@ -327,6 +327,7 @@ static void gemalto_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = gemalto_gprs_context_probe,
.remove = gemalto_gprs_context_remove,
.activate_primary = gemalto_gprs_activate_primary,
diff --git a/drivers/hsomodem/gprs-context.c b/drivers/hsomodem/gprs-context.c
index 85f16404cb76..3b3346b0309b 100644
--- a/drivers/hsomodem/gprs-context.c
+++ b/drivers/hsomodem/gprs-context.c
@@ -363,6 +363,7 @@ static void hso_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = hso_gprs_context_probe,
.remove = hso_gprs_context_remove,
.activate_primary = hso_gprs_activate_primary,
diff --git a/drivers/huaweimodem/gprs-context.c b/drivers/huaweimodem/gprs-context.c
index 81eecbeded11..9108d490e0c5 100644
--- a/drivers/huaweimodem/gprs-context.c
+++ b/drivers/huaweimodem/gprs-context.c
@@ -322,6 +322,7 @@ static void huawei_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = huawei_gprs_context_probe,
.remove = huawei_gprs_context_remove,
.activate_primary = huawei_gprs_activate_primary,
diff --git a/drivers/iceramodem/gprs-context.c b/drivers/iceramodem/gprs-context.c
index 1bfaf703905c..070017c1d529 100644
--- a/drivers/iceramodem/gprs-context.c
+++ b/drivers/iceramodem/gprs-context.c
@@ -389,6 +389,7 @@ static void icera_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = icera_gprs_context_probe,
.remove = icera_gprs_context_remove,
.activate_primary = icera_gprs_activate_primary,
diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c
index f39c874a299b..da4632b5ce42 100644
--- a/drivers/ifxmodem/gprs-context.c
+++ b/drivers/ifxmodem/gprs-context.c
@@ -724,6 +724,7 @@ static void ifx_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = ifx_gprs_context_probe,
.remove = ifx_gprs_context_remove,
.activate_primary = ifx_gprs_activate_primary,
diff --git a/drivers/isimodem/gprs-context.c b/drivers/isimodem/gprs-context.c
index ec4e9c15a69e..7d6fda2baf85 100644
--- a/drivers/isimodem/gprs-context.c
+++ b/drivers/isimodem/gprs-context.c
@@ -645,6 +645,7 @@ static void isi_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = isi_gprs_context_probe,
.remove = isi_gprs_context_remove,
.activate_primary = isi_gprs_activate_primary,
diff --git a/drivers/mbimmodem/gprs-context.c b/drivers/mbimmodem/gprs-context.c
index 0c2042d92919..c420e300aa57 100644
--- a/drivers/mbimmodem/gprs-context.c
+++ b/drivers/mbimmodem/gprs-context.c
@@ -440,6 +440,7 @@ static void mbim_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = mbim_gprs_context_probe,
.remove = mbim_gprs_context_remove,
.activate_primary = mbim_gprs_activate_primary,
diff --git a/drivers/mbmmodem/gprs-context.c b/drivers/mbmmodem/gprs-context.c
index 65668c36ef91..d9ea204da049 100644
--- a/drivers/mbmmodem/gprs-context.c
+++ b/drivers/mbmmodem/gprs-context.c
@@ -494,6 +494,7 @@ static void mbm_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = mbm_gprs_context_probe,
.remove = mbm_gprs_context_remove,
.activate_primary = mbm_gprs_activate_primary,
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 4b36d621630b..625fd0b8f193 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -608,6 +608,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_gprs_context_probe,
.remove = qmi_gprs_context_remove,
.activate_primary = qmi_activate_primary,
diff --git a/drivers/rilmodem/gprs-context.c b/drivers/rilmodem/gprs-context.c
index be47731b295c..42d12b0f3e94 100644
--- a/drivers/rilmodem/gprs-context.c
+++ b/drivers/rilmodem/gprs-context.c
@@ -842,6 +842,7 @@ static void ril_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = ril_gprs_context_probe,
.remove = ril_gprs_context_remove,
.activate_primary = ril_gprs_context_activate_primary,
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index e793c96cd4e3..a23c6f837ff4 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -412,6 +412,7 @@ out:
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = ste_gprs_context_probe,
.remove = ste_gprs_context_remove,
.activate_primary = ste_gprs_activate_primary,
diff --git a/drivers/swmodem/gprs-context.c b/drivers/swmodem/gprs-context.c
index 7de61871760e..32f8cef64c07 100644
--- a/drivers/swmodem/gprs-context.c
+++ b/drivers/swmodem/gprs-context.c
@@ -231,6 +231,7 @@ static void sw_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = sw_gprs_context_probe,
.remove = sw_gprs_context_remove,
.activate_primary = sw_gprs_activate_primary,
diff --git a/drivers/ubloxmodem/gprs-context.c b/drivers/ubloxmodem/gprs-context.c
index bba36ddd6c20..fab0207430b4 100644
--- a/drivers/ubloxmodem/gprs-context.c
+++ b/drivers/ubloxmodem/gprs-context.c
@@ -569,6 +569,7 @@ static void ublox_gprs_context_remove(struct ofono_gprs_context *gc)
}
static const struct ofono_gprs_context_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = ublox_gprs_context_probe,
.remove = ublox_gprs_context_remove,
.activate_primary = ublox_gprs_activate_primary,
diff --git a/include/audio-settings.h b/include/audio-settings.h
index 452d7e73632d..6b7eb0db1a7e 100644
--- a/include/audio-settings.h
+++ b/include/audio-settings.h
@@ -19,6 +19,7 @@ extern "C" {
struct ofono_audio_settings;
struct ofono_audio_settings_driver {
+ unsigned int flags;
int (*probe)(struct ofono_audio_settings *as,
unsigned int vendor, void *data);
int (*probev)(struct ofono_audio_settings *as,
diff --git a/include/call-barring.h b/include/call-barring.h
index 99e2764e64da..7ce787249a9e 100644
--- a/include/call-barring.h
+++ b/include/call-barring.h
@@ -24,6 +24,7 @@ typedef void (*ofono_call_barring_query_cb_t)(const struct ofono_error *error,
int status, void *data);
struct ofono_call_barring_driver {
+ unsigned int flags;
int (*probe)(struct ofono_call_barring *cb, unsigned int vendor,
void *data);
int (*probev)(struct ofono_call_barring *cb, unsigned int vendor,
diff --git a/include/call-forwarding.h b/include/call-forwarding.h
index 2eb2f1817b8d..3e58bb40e48f 100644
--- a/include/call-forwarding.h
+++ b/include/call-forwarding.h
@@ -34,6 +34,7 @@ typedef void (*ofono_call_forwarding_query_cb_t)(
void *data);
struct ofono_call_forwarding_driver {
+ unsigned int flags;
int (*probe)(struct ofono_call_forwarding *cf, unsigned int vendor,
void *data);
int (*probev)(struct ofono_call_forwarding *cf, unsigned int vendor,
diff --git a/include/call-meter.h b/include/call-meter.h
index 9a00104a2ede..455f1645ba0d 100644
--- a/include/call-meter.h
+++ b/include/call-meter.h
@@ -30,6 +30,7 @@ typedef void(*ofono_call_meter_set_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_call_meter_driver {
+ unsigned int flags;
int (*probe)(struct ofono_call_meter *cm, unsigned int vendor,
void *data);
int (*probev)(struct ofono_call_meter *cm, unsigned int vendor,
diff --git a/include/call-settings.h b/include/call-settings.h
index ced1047fd3d2..72c69df6ed20 100644
--- a/include/call-settings.h
+++ b/include/call-settings.h
@@ -28,6 +28,7 @@ typedef void (*ofono_call_settings_clir_cb_t)(const struct ofono_error *error,
int override, int network, void *data);
struct ofono_call_settings_driver {
+ unsigned int flags;
int (*probe)(struct ofono_call_settings *cs, unsigned int vendor,
void *data);
int (*probev)(struct ofono_call_settings *cs, unsigned int vendor,
diff --git a/include/call-volume.h b/include/call-volume.h
index 90629b25cc1f..5b95d1814d86 100644
--- a/include/call-volume.h
+++ b/include/call-volume.h
@@ -23,6 +23,7 @@ typedef void (*ofono_call_volume_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_call_volume_driver {
+ unsigned int flags;
int (*probe)(struct ofono_call_volume *cv, unsigned int vendor,
void *data);
int (*probev)(struct ofono_call_volume *cv, unsigned int vendor,
diff --git a/include/cbs.h b/include/cbs.h
index 9d3367b7b24f..07e08836db6e 100644
--- a/include/cbs.h
+++ b/include/cbs.h
@@ -22,6 +22,7 @@ typedef void (*ofono_cbs_set_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_cbs_driver {
+ unsigned int flags;
int (*probe)(struct ofono_cbs *cbs, unsigned int vendor, void *data);
int (*probev)(struct ofono_cbs *cbs, unsigned int vendor, va_list args);
void (*remove)(struct ofono_cbs *cbs);
diff --git a/include/ctm.h b/include/ctm.h
index 315fa5d562f3..19a7332dcc2b 100644
--- a/include/ctm.h
+++ b/include/ctm.h
@@ -25,6 +25,7 @@ typedef void (*ofono_ctm_query_cb_t)(const struct ofono_error *error,
ofono_bool_t enable, void *data);
struct ofono_ctm_driver {
+ unsigned int flags;
int (*probe)(struct ofono_ctm *ctm, unsigned int vendor, void *data);
int (*probev)(struct ofono_ctm *ctm, unsigned int vendor, va_list args);
void (*remove)(struct ofono_ctm *ctm);
diff --git a/include/devinfo.h b/include/devinfo.h
index ac553e959443..70190b8fcc62 100644
--- a/include/devinfo.h
+++ b/include/devinfo.h
@@ -22,6 +22,7 @@ typedef void (*ofono_devinfo_query_cb_t)(const struct ofono_error *error,
const char *attribute, void *data);
struct ofono_devinfo_driver {
+ unsigned int flags;
int (*probe)(struct ofono_devinfo *info, unsigned int vendor,
void *data);
int (*probev)(struct ofono_devinfo *info, unsigned int vendor,
diff --git a/include/gnss.h b/include/gnss.h
index dd1b79246f72..5df31791ef80 100644
--- a/include/gnss.h
+++ b/include/gnss.h
@@ -22,6 +22,7 @@ struct ofono_gnss;
typedef void (*ofono_gnss_cb_t)(const struct ofono_error *error, void *data);
struct ofono_gnss_driver {
+ unsigned int flags;
int (*probe)(struct ofono_gnss *gnss, unsigned int vendor, void *data);
int (*probev)(struct ofono_gnss *gnss, unsigned int vendor,
va_list args);
diff --git a/include/gprs-context.h b/include/gprs-context.h
index 2bc9dd166787..0002724acbd3 100644
--- a/include/gprs-context.h
+++ b/include/gprs-context.h
@@ -42,6 +42,7 @@ typedef void (*ofono_gprs_context_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_gprs_context_driver {
+ unsigned int flags;
int (*probe)(struct ofono_gprs_context *gc, unsigned int vendor,
void *data);
int (*probev)(struct ofono_gprs_context *gc, unsigned int vendor,
diff --git a/include/gprs.h b/include/gprs.h
index 62bf05baf30b..df288a125de4 100644
--- a/include/gprs.h
+++ b/include/gprs.h
@@ -25,6 +25,7 @@ typedef void (*ofono_gprs_status_cb_t)(const struct ofono_error *error,
typedef void (*ofono_gprs_cb_t)(const struct ofono_error *error, void *data);
struct ofono_gprs_driver {
+ unsigned int flags;
int (*probe)(struct ofono_gprs *gprs, unsigned int vendor,
void *data);
int (*probev)(struct ofono_gprs *gprs, unsigned int vendor,
diff --git a/include/handsfree.h b/include/handsfree.h
index 43fe572693f6..19eeb52bd802 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -30,6 +30,7 @@ typedef void (*ofono_handsfree_cnum_query_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_handsfree_driver {
+ unsigned int flags;
int (*probe)(struct ofono_handsfree *hf, unsigned int vendor,
void *data);
int (*probev)(struct ofono_handsfree *hf, unsigned int vendor,
diff --git a/include/ims.h b/include/ims.h
index c394d5160c26..cee3ff804b37 100644
--- a/include/ims.h
+++ b/include/ims.h
@@ -25,6 +25,7 @@ typedef void (*ofono_ims_status_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_ims_driver {
+ unsigned int flags;
int (*probe)(struct ofono_ims *ims, unsigned int vendor, void *data);
int (*probev)(struct ofono_ims *ims, unsigned int vendor, va_list args);
void (*remove)(struct ofono_ims *ims);
diff --git a/include/location-reporting.h b/include/location-reporting.h
index 7faf0ba3c485..75900eb5738c 100644
--- a/include/location-reporting.h
+++ b/include/location-reporting.h
@@ -31,6 +31,7 @@ typedef void (*ofono_location_reporting_disable_cb_t)(
void *data);
struct ofono_location_reporting_driver {
+ unsigned int flags;
enum ofono_location_reporting_type type;
int (*probe)(struct ofono_location_reporting *lr, unsigned int vendor,
void *data);
diff --git a/include/lte.h b/include/lte.h
index 3f8dbd535e69..91a15fdcc1a0 100644
--- a/include/lte.h
+++ b/include/lte.h
@@ -30,6 +30,7 @@ struct ofono_lte_default_attach_info {
typedef void (*ofono_lte_cb_t)(const struct ofono_error *error, void *data);
struct ofono_lte_driver {
+ unsigned int flags;
int (*probe)(struct ofono_lte *lte, unsigned int vendor, void *data);
int (*probev)(struct ofono_lte *lte, unsigned int vendor, va_list args);
void (*remove)(struct ofono_lte *lte);
diff --git a/include/modem.h b/include/modem.h
index 08a7012acae4..65cb3a15bc95 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -41,6 +41,8 @@ struct ofono_driver_desc {
const void *driver;
} __attribute__((aligned(8)));
+#define OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE 0x1
+
#define OFONO_ATOM_DRIVER_BUILTIN(type, name, driver) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
diff --git a/include/netmon.h b/include/netmon.h
index d1eef952314e..7eac8d070c80 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -21,6 +21,7 @@ struct ofono_netmon;
typedef void (*ofono_netmon_cb_t)(const struct ofono_error *error, void *data);
struct ofono_netmon_driver {
+ unsigned int flags;
int (*probe)(struct ofono_netmon *netmon, unsigned int vendor,
void *data);
int (*probev)(struct ofono_netmon *netmon, unsigned int vendor,
diff --git a/include/netreg.h b/include/netreg.h
index 48a13e161fea..8d11518aa239 100644
--- a/include/netreg.h
+++ b/include/netreg.h
@@ -57,6 +57,7 @@ typedef void (*ofono_netreg_strength_cb_t)(const struct ofono_error *error,
* vendor extensions for signal strength notification.
*/
struct ofono_netreg_driver {
+ unsigned int flags;
int (*probe)(struct ofono_netreg *netreg, unsigned int vendor,
void *data);
int (*probev)(struct ofono_netreg *netreg, unsigned int vendor,
diff --git a/include/phonebook.h b/include/phonebook.h
index 2c895fa9cf13..fbe689618215 100644
--- a/include/phonebook.h
+++ b/include/phonebook.h
@@ -39,6 +39,7 @@ typedef void (*ofono_phonebook_cb_t)(const struct ofono_error *error,
* occurs, ofono_phonebook_entry should not be called
*/
struct ofono_phonebook_driver {
+ unsigned int flags;
int (*probe)(struct ofono_phonebook *pb, unsigned int vendor,
void *data);
int (*probev)(struct ofono_phonebook *pb, unsigned int vendor,
diff --git a/include/radio-settings.h b/include/radio-settings.h
index 7dcccf81d226..487963c589d7 100644
--- a/include/radio-settings.h
+++ b/include/radio-settings.h
@@ -73,6 +73,7 @@ typedef void (*ofono_radio_settings_available_rats_query_cb_t)(
void *data);
struct ofono_radio_settings_driver {
+ unsigned int flags;
int (*probe)(struct ofono_radio_settings *rs, unsigned int vendor,
void *data);
int (*probev)(struct ofono_radio_settings *rs, unsigned int vendor,
diff --git a/include/sim.h b/include/sim.h
index c362cc0ecb62..84592fc93e5a 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -125,6 +125,7 @@ typedef void (*ofono_sim_set_active_card_slot_cb_t)(
void *data);
struct ofono_sim_driver {
+ unsigned int flags;
int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
int (*probev)(struct ofono_sim *sim, unsigned int vendor, va_list args);
void (*remove)(struct ofono_sim *sim);
diff --git a/include/siri.h b/include/siri.h
index 0a9702b2037a..7a41694f0c09 100644
--- a/include/siri.h
+++ b/include/siri.h
@@ -22,6 +22,7 @@ typedef void (*ofono_siri_cb_t)(const struct ofono_error *error,
struct ofono_siri *siri);
struct ofono_siri_driver {
+ unsigned int flags;
int (*probe)(struct ofono_siri *siri, unsigned int vendor, void *data);
int (*probev)(struct ofono_siri *siri, unsigned int vendor,
va_list args);
diff --git a/include/sms.h b/include/sms.h
index d843ae6ae122..ba98c5e44287 100644
--- a/include/sms.h
+++ b/include/sms.h
@@ -31,6 +31,7 @@ typedef void (*ofono_sms_bearer_query_cb_t)(const struct ofono_error *error,
int bearer, void *data);
struct ofono_sms_driver {
+ unsigned int flags;
int (*probe)(struct ofono_sms *sms, unsigned int vendor, void *data);
int (*probev)(struct ofono_sms *sms, unsigned int vendor, va_list args);
void (*remove)(struct ofono_sms *sms);
diff --git a/include/stk.h b/include/stk.h
index 8575b2819b4a..b99f6ba255e4 100644
--- a/include/stk.h
+++ b/include/stk.h
@@ -26,6 +26,7 @@ typedef void (*ofono_stk_generic_cb_t)(const struct ofono_error *error,
void *data);
struct ofono_stk_driver {
+ unsigned int flags;
int (*probe)(struct ofono_stk *stk, unsigned int vendor, void *data);
int (*probev)(struct ofono_stk *stk, unsigned int vendor, va_list args);
void (*remove)(struct ofono_stk *stk);
diff --git a/include/ussd.h b/include/ussd.h
index 04a91e8483b7..1b928171ef9e 100644
--- a/include/ussd.h
+++ b/include/ussd.h
@@ -31,6 +31,7 @@ struct ofono_ussd;
typedef void (*ofono_ussd_cb_t)(const struct ofono_error *error, void *data);
struct ofono_ussd_driver {
+ unsigned int flags;
int (*probe)(struct ofono_ussd *ussd, unsigned int vendor, void *data);
int (*probev)(struct ofono_ussd *ussd, unsigned int vendor,
va_list args);
diff --git a/include/voicecall.h b/include/voicecall.h
index 345e52b15a0e..370658369538 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -29,6 +29,7 @@ typedef void (*ofono_voicecall_cb_t)(const struct ofono_error *error,
* not support vendor extensions for call progress indication.
*/
struct ofono_voicecall_driver {
+ unsigned int flags;
int (*probe)(struct ofono_voicecall *vc, unsigned int vendor,
void *data);
int (*probev)(struct ofono_voicecall *vc, unsigned int vendor,
diff --git a/src/gprs.c b/src/gprs.c
index 28b3ddff6584..57b823b0f1c6 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -2806,6 +2806,10 @@ static void gprs_context_remove(struct ofono_atom *atom)
g_free(gc);
}
+static void ofono_gprs_context_register(struct ofono_gprs_context *gc)
+{
+}
+
OFONO_DEFINE_ATOM_CREATE(gprs_context, OFONO_ATOM_TYPE_GPRS_CONTEXT, {
atom->type = OFONO_GPRS_CONTEXT_TYPE_ANY;
})
diff --git a/src/ofono.h b/src/ofono.h
index c6fa16f2dc01..a853bba60ce6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -263,6 +263,11 @@ struct ofono_ ## type *ofono_ ## type ##_create( \
} \
\
atom->driver = drv; \
+ \
+ if (atom->driver->flags & \
+ OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE) \
+ ofono_ ## type ##_register(atom); \
+ \
return atom; \
}
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 06/23] qmi: introduce qmi_service_clone
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (3 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 05/23] core: Support register on probe flag Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 07/23] gobi: request needed services at .enable() Denis Kenzior
` (17 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Allows obtaining a new lightweight qmi_service handle from an existing
handle. All outstanding requests (sent using qmi_service_send) and
registrations (qmi_service_register) will be automatically canceled when
the lightweight handle is freed.
---
drivers/qmimodem/qmi.c | 8 ++++++++
drivers/qmimodem/qmi.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 1b3fa34f685c..91469dc2e00c 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -2918,6 +2918,14 @@ static bool qmi_service_unregister_all(struct qmi_service *service)
return true;
}
+struct qmi_service *qmi_service_clone(struct qmi_service *service)
+{
+ if (!service)
+ return NULL;
+
+ return service_create(service->family);
+}
+
void qmi_service_free(struct qmi_service *service)
{
if (!service)
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 227c498ab41d..821e54443658 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -139,6 +139,7 @@ typedef void (*qmi_create_func_t)(struct qmi_service *service, void *user_data);
bool qmi_service_create_shared(struct qmi_device *device,
uint16_t type, qmi_create_func_t func,
void *user_data, qmi_destroy_func_t destroy);
+struct qmi_service *qmi_service_clone(struct qmi_service *service);
void qmi_service_free(struct qmi_service *service);
const char *qmi_service_get_identifier(struct qmi_service *service);
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 07/23] gobi: request needed services at .enable()
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (4 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 06/23] qmi: introduce qmi_service_clone Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 08/23] qmi: devinfo: Drop use of qmi_service_create_shared Denis Kenzior
` (16 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Request all needed services when the modem is being powered up via
.enable method.
---
plugins/gobi.c | 100 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 85 insertions(+), 15 deletions(-)
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 10ce2acc0cca..ea4d633c3406 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -60,10 +60,24 @@ enum qmi_protocol {
QMI_PROTOCOL_QRTR,
};
+struct service_request {
+ struct qmi_service **member;
+ uint32_t service_type;
+};
+
struct gobi_data {
struct qmi_device *device;
struct qmi_service *dms;
struct qmi_service *wda;
+ struct qmi_service *nas;
+ struct qmi_service *wds;
+ struct qmi_service *wms;
+ struct qmi_service *voice;
+ struct qmi_service *pds;
+ struct qmi_service *uim;
+ struct service_request service_requests[16];
+ int cur_service_request;
+ int num_service_requests;
unsigned long features;
unsigned int discover_attempts;
uint8_t oper_mode;
@@ -161,6 +175,24 @@ static void cleanup_services(struct gobi_data *data)
qmi_service_free(data->wda);
data->wda = NULL;
+
+ qmi_service_free(data->nas);
+ data->nas = NULL;
+
+ qmi_service_free(data->wds);
+ data->wds = NULL;
+
+ qmi_service_free(data->wms);
+ data->wms = NULL;
+
+ qmi_service_free(data->voice);
+ data->voice = NULL;
+
+ qmi_service_free(data->pds);
+ data->pds = NULL;
+
+ qmi_service_free(data->uim);
+ data->uim = NULL;
}
static void gobi_remove(struct ofono_modem *modem)
@@ -183,6 +215,21 @@ static void gobi_remove(struct ofono_modem *modem)
l_free(data);
}
+static void add_service_request(struct gobi_data *data,
+ struct qmi_service **member,
+ uint32_t service_type)
+{
+ struct service_request req = { .member = member,
+ .service_type = service_type };
+
+ if (data->num_service_requests == L_ARRAY_SIZE(data->service_requests)) {
+ ofono_error("No room to add service request");
+ return;
+ }
+
+ data->service_requests[data->num_service_requests++] = req;
+}
+
static void shutdown_cb(void *user_data)
{
struct ofono_modem *modem = user_data;
@@ -376,34 +423,42 @@ error:
shutdown_device(modem);
}
-static void create_dms_cb(struct qmi_service *service, void *user_data)
+static void request_service_cb(struct qmi_service *service, void *user_data)
{
struct ofono_modem *modem = user_data;
struct gobi_data *data = ofono_modem_get_data(modem);
+ struct service_request *req =
+ &data->service_requests[data->cur_service_request];
DBG("");
if (!service)
goto error;
- data->dms = service;
+ *req->member = service;
- if (qmi_service_create_shared(data->device, QMI_SERVICE_WDA,
- create_wda_cb, modem, NULL))
+ data->cur_service_request += 1;
+ if (data->cur_service_request == data->num_service_requests) {
+ DBG("All services requested, proceeding to create WDA");
+
+ if (qmi_service_create_shared(data->device, QMI_SERVICE_WDA,
+ create_wda_cb, modem, NULL))
+ return;
+
+ goto error;
+ }
+
+ req = &data->service_requests[data->cur_service_request];
+ DBG("Requesting: %u", req->service_type);
+
+ if (qmi_service_create_shared(data->device, req->service_type,
+ request_service_cb, modem, NULL))
return;
error:
shutdown_device(modem);
}
-static void create_shared_dms(struct ofono_modem *modem)
-{
- struct gobi_data *data = ofono_modem_get_data(modem);
-
- qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
- create_dms_cb, modem, NULL);
-}
-
static void discover_cb(void *user_data)
{
struct ofono_modem *modem = user_data;
@@ -434,11 +489,26 @@ static void discover_cb(void *user_data)
modem, NULL))
return;
- shutdown_device(modem);
- return;
+ goto error;
}
- create_shared_dms(modem);
+ add_service_request(data, &data->dms, QMI_SERVICE_DMS);
+ if (data->features & GOBI_NAS)
+ add_service_request(data, &data->nas, QMI_SERVICE_NAS);
+ if (data->features & GOBI_WDS)
+ add_service_request(data, &data->wds, QMI_SERVICE_WDS);
+ if (data->features & GOBI_WMS)
+ add_service_request(data, &data->wms, QMI_SERVICE_WMS);
+ if (data->features & GOBI_VOICE)
+ add_service_request(data, &data->voice, QMI_SERVICE_VOICE);
+ if (data->features & GOBI_UIM)
+ add_service_request(data, &data->uim, QMI_SERVICE_UIM);
+
+ if (qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
+ request_service_cb, modem, NULL) > 0)
+ return;
+error:
+ shutdown_device(modem);
}
static int gobi_enable(struct ofono_modem *modem)
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 08/23] qmi: devinfo: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (5 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 07/23] gobi: request needed services at .enable() Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 09/23] qmi: sim-legacy: " Denis Kenzior
` (15 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Send qmi_service directly to the devinfo atom, which will clone it
during probe, obtaining its own lightweight handle.
---
drivers/qmimodem/devinfo.c | 45 +++++++-------------------------------
plugins/gobi.c | 2 +-
2 files changed, 9 insertions(+), 38 deletions(-)
diff --git a/drivers/qmimodem/devinfo.c b/drivers/qmimodem/devinfo.c
index b74e535aaeb8..2e514cfa3265 100644
--- a/drivers/qmimodem/devinfo.c
+++ b/drivers/qmimodem/devinfo.c
@@ -192,53 +192,25 @@ error:
ofono_devinfo_register(devinfo);
}
-static void qmi_query_caps(struct ofono_devinfo *devinfo)
-{
- struct devinfo_data *data = ofono_devinfo_get_data(devinfo);
-
- DBG("");
-
- if (qmi_service_send(data->dms, QMI_DMS_GET_CAPS, NULL,
- get_caps_cb, devinfo, NULL) > 0)
- return;
-
- ofono_devinfo_register(devinfo);
-}
-
-static void create_dms_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_devinfo *devinfo = user_data;
- struct devinfo_data *data = ofono_devinfo_get_data(devinfo);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request DMS service");
- ofono_devinfo_remove(devinfo);
- return;
- }
-
- data->dms = service;
- data->device_is_3gpp = false;
-
- qmi_query_caps(devinfo);
-}
-
static int qmi_devinfo_probe(struct ofono_devinfo *devinfo,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *dms = user_data;
struct devinfo_data *data;
DBG("");
+ if (!qmi_service_send(dms, QMI_DMS_GET_CAPS, NULL,
+ get_caps_cb, devinfo, NULL)) {
+ qmi_service_free(dms);
+ return -EIO;
+ }
+
data = l_new(struct devinfo_data, 1);
+ data->dms = dms;
ofono_devinfo_set_data(devinfo, data);
- qmi_service_create_shared(device, QMI_SERVICE_DMS,
- create_dms_cb, devinfo, NULL);
-
return 0;
}
@@ -251,7 +223,6 @@ static void qmi_devinfo_remove(struct ofono_devinfo *devinfo)
ofono_devinfo_set_data(devinfo, NULL);
qmi_service_free(data->dms);
-
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index ea4d633c3406..1817f7b5ee2a 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -713,7 +713,7 @@ static void gobi_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "qmimodem", data->device);
+ ofono_devinfo_create(modem, 0, "qmimodem", qmi_service_clone(data->dms));
if (data->features & GOBI_UIM)
sim_driver = "qmimodem";
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 09/23] qmi: sim-legacy: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (6 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 08/23] qmi: devinfo: Drop use of qmi_service_create_shared Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 10/23] qmi: voicecall: " Denis Kenzior
` (14 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
While here, also drop tracking of indication registration. This is not
needed as qmi_service_free will automatically unregister from all
indications for the cloned handle.
---
drivers/qmimodem/sim-legacy.c | 57 +++++++++--------------------------
plugins/gobi.c | 17 ++++-------
2 files changed, 20 insertions(+), 54 deletions(-)
diff --git a/drivers/qmimodem/sim-legacy.c b/drivers/qmimodem/sim-legacy.c
index aeea5fae22f3..1feaf86976c6 100644
--- a/drivers/qmimodem/sim-legacy.c
+++ b/drivers/qmimodem/sim-legacy.c
@@ -27,7 +27,6 @@
struct sim_data {
struct qmi_service *dms;
int retries[OFONO_SIM_PASSWORD_INVALID];
- uint16_t event_indication_id;
};
static void qmi_read_file_info(struct ofono_sim *sim, int fileid,
@@ -295,59 +294,37 @@ done:
ofono_sim_register(sim);
}
-static void create_dms_cb(struct qmi_service *service, void *user_data)
+static int qmi_sim_probe(struct ofono_sim *sim,
+ unsigned int vendor, void *user_data)
{
- struct ofono_sim *sim = user_data;
- struct sim_data *data = ofono_sim_get_data(sim);
+ struct qmi_service *dms = user_data;
struct qmi_param *param;
+ struct sim_data *data;
+ int i;
DBG("");
- if (!service) {
- ofono_error("Failed to request DMS service");
- ofono_sim_remove(sim);
- return;
- }
-
- data->dms = service;
-
- data->event_indication_id =
- qmi_service_register(data->dms, QMI_DMS_EVENT,
- event_notify, sim, NULL);
-
param = qmi_param_new();
-
qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_PIN_STATUS, 0x01);
qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_OPER_MODE, 0x01);
qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_UIM_STATE, 0x01);
- if (qmi_service_send(data->dms, QMI_DMS_SET_EVENT, param,
- set_event_cb, sim, NULL) > 0)
- return;
-
- qmi_param_free(param);
-
- ofono_sim_register(sim);
-}
-
-static int qmi_sim_probe(struct ofono_sim *sim,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct sim_data *data;
- int i;
-
- DBG("");
+ if (!qmi_service_send(dms, QMI_DMS_SET_EVENT, param,
+ set_event_cb, sim, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(dms);
+ return -EIO;
+ }
data = l_new(struct sim_data, 1);
+ data->dms = dms;
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
data->retries[i] = -1;
- ofono_sim_set_data(sim, data);
+ qmi_service_register(dms, QMI_DMS_EVENT, event_notify, sim, NULL);
- qmi_service_create_shared(device, QMI_SERVICE_DMS,
- create_dms_cb, sim, NULL);
+ ofono_sim_set_data(sim, data);
return 0;
}
@@ -360,13 +337,7 @@ static void qmi_sim_remove(struct ofono_sim *sim)
ofono_sim_set_data(sim, NULL);
- if (data->event_indication_id) {
- qmi_service_unregister(data->dms, data->event_indication_id);
- data->event_indication_id = 0;
- }
-
qmi_service_free(data->dms);
-
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 1817f7b5ee2a..deeccb7879f2 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -709,22 +709,17 @@ static void gobi_set_online(struct ofono_modem *modem, ofono_bool_t online,
static void gobi_pre_sim(struct ofono_modem *modem)
{
struct gobi_data *data = ofono_modem_get_data(modem);
- const char *sim_driver = NULL;
+ bool legacy = ofono_modem_get_boolean(modem, "ForceSimLegacy");
DBG("%p", modem);
ofono_devinfo_create(modem, 0, "qmimodem", qmi_service_clone(data->dms));
- if (data->features & GOBI_UIM)
- sim_driver = "qmimodem";
- else if (data->features & GOBI_DMS)
- sim_driver = "qmimodem_legacy";
-
- if (ofono_modem_get_boolean(modem, "ForceSimLegacy"))
- sim_driver = "qmimodem_legacy";
-
- if (sim_driver)
- ofono_sim_create(modem, 0, sim_driver, data->device);
+ if ((data->features & GOBI_UIM) && !legacy)
+ ofono_sim_create(modem, 0, "qmimodem", data->device);
+ else /* DMS always available */
+ ofono_sim_create(modem, 0, "qmimodem_legacy",
+ qmi_service_clone(data->dms));
if (data->features & GOBI_VOICE)
ofono_voicecall_create(modem, 0, "qmimodem", data->device);
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 10/23] qmi: voicecall: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (7 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 09/23] qmi: sim-legacy: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 11/23] qmi: call-barring: " Denis Kenzior
` (13 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/voicecall.c | 40 ++++++++----------------------------
plugins/gobi.c | 3 ++-
2 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c
index 6af85caa840a..c7a5230f9680 100644
--- a/drivers/qmimodem/voicecall.c
+++ b/drivers/qmimodem/voicecall.c
@@ -709,48 +709,24 @@ static void send_dtmf(struct ofono_voicecall *vc, const char *dtmf,
send_one_dtmf(vc, *dtmf, send_one_dtmf_cb, vd);
}
-static void create_voice_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_voicecall *vc = user_data;
- struct voicecall_data *data = ofono_voicecall_get_data(vc);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request Voice service");
- ofono_voicecall_remove(vc);
- return;
- }
-
- if (!qmi_service_get_version(service, &data->major, &data->minor)) {
- ofono_error("Failed to get Voice service version");
- ofono_voicecall_remove(vc);
- return;
- }
-
- data->voice = service;
-
- qmi_service_register(data->voice, QMI_VOICE_ALL_CALL_STATUS_IND,
- all_call_status_ind, vc, NULL);
-
- ofono_voicecall_register(vc);
-}
-
static int qmi_voicecall_probe(struct ofono_voicecall *vc,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *voice = user_data;
struct voicecall_data *data;
DBG("");
data = l_new(struct voicecall_data, 1);
+ data->voice = voice;
data->call_list = l_queue_new();
- ofono_voicecall_set_data(vc, data);
+ qmi_service_get_version(data->voice, &data->major, &data->minor);
+
+ qmi_service_register(data->voice, QMI_VOICE_ALL_CALL_STATUS_IND,
+ all_call_status_ind, vc, NULL);
- qmi_service_create_shared(device, QMI_SERVICE_VOICE,
- create_voice_cb, vc, NULL);
+ ofono_voicecall_set_data(vc, data);
return 0;
}
@@ -764,13 +740,13 @@ static void qmi_voicecall_remove(struct ofono_voicecall *vc)
ofono_voicecall_set_data(vc, NULL);
qmi_service_free(data->voice);
-
l_queue_destroy(data->call_list, l_free);
l_free(data->full_dtmf);
l_free(data);
}
static const struct ofono_voicecall_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_voicecall_probe,
.remove = qmi_voicecall_remove,
.dial = dial,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index deeccb7879f2..0494959dc838 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -722,7 +722,8 @@ static void gobi_pre_sim(struct ofono_modem *modem)
qmi_service_clone(data->dms));
if (data->features & GOBI_VOICE)
- ofono_voicecall_create(modem, 0, "qmimodem", data->device);
+ ofono_voicecall_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->voice));
if (data->features & GOBI_PDS)
ofono_location_reporting_create(modem, 0, "qmimodem",
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 11/23] qmi: call-barring: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (8 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 10/23] qmi: voicecall: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 12/23] qmi: call-forwarding: " Denis Kenzior
` (12 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/call-barring.c | 29 ++++-------------------------
plugins/gobi.c | 3 ++-
2 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/qmimodem/call-barring.c b/drivers/qmimodem/call-barring.c
index 2209b4049c13..8da805cfe6ca 100644
--- a/drivers/qmimodem/call-barring.c
+++ b/drivers/qmimodem/call-barring.c
@@ -190,39 +190,19 @@ error:
CALLBACK_WITH_FAILURE(cb, data);
}
-static void create_voice_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_call_barring *barr = user_data;
- struct call_barring_data *bd = ofono_call_barring_get_data(barr);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request Voice service");
- ofono_call_barring_remove(barr);
- return;
- }
-
- bd->voice = service;
-
- ofono_call_barring_register(barr);
-}
-
static int qmi_call_barring_probe(struct ofono_call_barring *barr,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *voice = user_data;
struct call_barring_data *bd;
DBG("");
bd = l_new(struct call_barring_data, 1);
+ bd->voice = voice;
ofono_call_barring_set_data(barr, bd);
- qmi_service_create_shared(device, QMI_SERVICE_VOICE,
- create_voice_cb, barr, NULL);
-
return 0;
}
@@ -234,13 +214,12 @@ static void qmi_call_barring_remove(struct ofono_call_barring *barr)
ofono_call_barring_set_data(barr, NULL);
- if (bd->voice)
- qmi_service_free(bd->voice);
-
+ qmi_service_free(bd->voice);
l_free(bd);
}
static const struct ofono_call_barring_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_call_barring_probe,
.remove = qmi_call_barring_remove,
.set = qmi_set,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 0494959dc838..7c6885b79c7c 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -835,7 +835,8 @@ static void gobi_post_online(struct ofono_modem *modem)
if (data->features & GOBI_VOICE) {
ofono_ussd_create(modem, 0, "qmimodem", data->device);
ofono_call_settings_create(modem, 0, "qmimodem", data->device);
- ofono_call_barring_create(modem, 0, "qmimodem", data->device);
+ ofono_call_barring_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->voice));
ofono_call_forwarding_create(modem, 0, "qmimodem",
data->device);
}
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 12/23] qmi: call-forwarding: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (9 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 11/23] qmi: call-barring: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 13/23] qmi: call-settings: " Denis Kenzior
` (11 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/call-forwarding.c | 29 ++++-------------------------
plugins/gobi.c | 2 +-
2 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/qmimodem/call-forwarding.c b/drivers/qmimodem/call-forwarding.c
index 191f3db75645..e7ae35153b09 100644
--- a/drivers/qmimodem/call-forwarding.c
+++ b/drivers/qmimodem/call-forwarding.c
@@ -276,39 +276,19 @@ static void qmi_erase(struct ofono_call_forwarding *cf, int type, int cls,
qmi_set(cf, type, cls, QMI_VOICE_SS_ACTION_ERASE, cb, data);
}
-static void create_voice_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_call_forwarding *cf = user_data;
- struct call_forwarding_data *cfd = ofono_call_forwarding_get_data(cf);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request Voice service");
- ofono_call_forwarding_remove(cf);
- return;
- }
-
- cfd->voice = service;
-
- ofono_call_forwarding_register(cf);
-}
-
static int qmi_call_forwarding_probe(struct ofono_call_forwarding *cf,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *voice = user_data;
struct call_forwarding_data *cfd;
DBG("");
cfd = l_new(struct call_forwarding_data, 1);
+ cfd->voice = voice;
ofono_call_forwarding_set_data(cf, cfd);
- qmi_service_create_shared(device, QMI_SERVICE_VOICE,
- create_voice_cb, cf, NULL);
-
return 0;
}
@@ -320,13 +300,12 @@ static void qmi_call_forwarding_remove(struct ofono_call_forwarding *cf)
ofono_call_forwarding_set_data(cf, NULL);
- if (cfd->voice)
- qmi_service_free(cfd->voice);
-
+ qmi_service_free(cfd->voice);
l_free(cfd);
}
static const struct ofono_call_forwarding_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_call_forwarding_probe,
.remove = qmi_call_forwarding_remove,
.registration = qmi_register,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 7c6885b79c7c..85ab427e9de5 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -838,7 +838,7 @@ static void gobi_post_online(struct ofono_modem *modem)
ofono_call_barring_create(modem, 0, "qmimodem",
qmi_service_clone(data->voice));
ofono_call_forwarding_create(modem, 0, "qmimodem",
- data->device);
+ qmi_service_clone(data->voice));
}
}
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 13/23] qmi: call-settings: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (10 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 12/23] qmi: call-forwarding: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 14/23] qmi: ussd: " Denis Kenzior
` (10 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
While here, drop 'sups_ind_id' member. Explicitly unregistering from a
an indication is not required. All indication registrations will be
automatically dropped when the service handle is freed using
qmi_service_free()
---
drivers/qmimodem/call-settings.c | 37 ++++++--------------------------
plugins/gobi.c | 3 ++-
2 files changed, 8 insertions(+), 32 deletions(-)
diff --git a/drivers/qmimodem/call-settings.c b/drivers/qmimodem/call-settings.c
index 676b39aaf487..3611c98894a0 100644
--- a/drivers/qmimodem/call-settings.c
+++ b/drivers/qmimodem/call-settings.c
@@ -21,7 +21,6 @@
struct call_settings_data {
struct qmi_service *voice;
- uint16_t sups_ind_id;
};
static void query_status(struct ofono_call_settings *cs, uint16_t message,
@@ -262,41 +261,20 @@ static void sups_ind(struct qmi_result *result, void *user_data)
clip->active, clip->provisioned);
}
-static void create_voice_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_call_settings *cs = user_data;
- struct call_settings_data *csd = ofono_call_settings_get_data(cs);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request Voice service");
- ofono_call_settings_remove(cs);
- return;
- }
-
- csd->voice = service;
-
- csd->sups_ind_id = qmi_service_register(csd->voice, QMI_VOICE_SUPS_IND,
- sups_ind, cs, NULL);
-
- ofono_call_settings_register(cs);
-}
-
static int qmi_call_settings_probe(struct ofono_call_settings *cs,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *voice = user_data;
struct call_settings_data *csd;
DBG("");
csd = l_new(struct call_settings_data, 1);
+ csd->voice = voice;
- ofono_call_settings_set_data(cs, csd);
+ qmi_service_register(csd->voice, QMI_VOICE_SUPS_IND, sups_ind, cs, NULL);
- qmi_service_create_shared(device, QMI_SERVICE_VOICE,
- create_voice_cb, cs, NULL);
+ ofono_call_settings_set_data(cs, csd);
return 0;
}
@@ -309,15 +287,12 @@ static void qmi_call_settings_remove(struct ofono_call_settings *cs)
ofono_call_settings_set_data(cs, NULL);
- if (csd->voice) {
- qmi_service_unregister(csd->voice, csd->sups_ind_id);
- qmi_service_free(csd->voice);
- }
-
+ qmi_service_free(csd->voice);
l_free(csd);
}
static const struct ofono_call_settings_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_call_settings_probe,
.remove = qmi_call_settings_remove,
.clip_query = qmi_clip_query,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 85ab427e9de5..17160354c273 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -834,7 +834,8 @@ static void gobi_post_online(struct ofono_modem *modem)
if (data->features & GOBI_VOICE) {
ofono_ussd_create(modem, 0, "qmimodem", data->device);
- ofono_call_settings_create(modem, 0, "qmimodem", data->device);
+ ofono_call_settings_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->voice));
ofono_call_barring_create(modem, 0, "qmimodem",
qmi_service_clone(data->voice));
ofono_call_forwarding_create(modem, 0, "qmimodem",
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 14/23] qmi: ussd: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (11 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 13/23] qmi: call-settings: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 15/23] qmi: location-reporting: " Denis Kenzior
` (9 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/ussd.c | 41 ++++++++---------------------------------
plugins/gobi.c | 3 ++-
2 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/drivers/qmimodem/ussd.c b/drivers/qmimodem/ussd.c
index ec9b60ff1222..6637ae759c55 100644
--- a/drivers/qmimodem/ussd.c
+++ b/drivers/qmimodem/ussd.c
@@ -145,51 +145,26 @@ error:
ofono_ussd_notify(ussd, OFONO_USSD_STATUS_TERMINATED, 0, NULL, 0);
}
-static void create_voice_cb(struct qmi_service *service, void *user_data)
+static int qmi_ussd_probe(struct ofono_ussd *ussd,
+ unsigned int vendor, void *user_data)
{
- struct ofono_ussd *ussd = user_data;
- struct ussd_data *data = ofono_ussd_get_data(ussd);
+ struct qmi_service *voice = user_data;
+ struct ussd_data *data;
DBG("");
- if (service == NULL) {
- ofono_error("Failed to request Voice service");
- ofono_ussd_remove(ussd);
- return;
- }
-
- if (!qmi_service_get_version(service, &data->major, &data->minor)) {
- ofono_error("Failed to get Voice service version");
- ofono_ussd_remove(ussd);
- return;
- }
-
- data->voice = service;
+ data = l_new(struct ussd_data, 1);
+ data->voice = voice;
+ qmi_service_get_version(data->voice, &data->major, &data->minor);
qmi_service_register(data->voice, QMI_VOICE_USSD_IND,
async_ind, ussd, NULL);
-
qmi_service_register(data->voice, QMI_VOICE_ASYNC_ORIG_USSD,
async_orig_ind, ussd, NULL);
- ofono_ussd_register(ussd);
-}
-
-static int qmi_ussd_probe(struct ofono_ussd *ussd,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct ussd_data *data;
-
- DBG("");
-
- data = l_new(struct ussd_data, 1);
ofono_ussd_set_data(ussd, data);
- qmi_service_create_shared(device, QMI_SERVICE_VOICE,
- create_voice_cb, ussd, NULL);
-
return 0;
}
@@ -202,7 +177,6 @@ static void qmi_ussd_remove(struct ofono_ussd *ussd)
ofono_ussd_set_data(ussd, NULL);
qmi_service_free(data->voice);
-
l_free(data);
}
@@ -298,6 +272,7 @@ error:
}
static const struct ofono_ussd_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_ussd_probe,
.remove = qmi_ussd_remove,
.request = qmi_ussd_request,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 17160354c273..456a5d2363eb 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -833,7 +833,8 @@ static void gobi_post_online(struct ofono_modem *modem)
}
if (data->features & GOBI_VOICE) {
- ofono_ussd_create(modem, 0, "qmimodem", data->device);
+ ofono_ussd_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->voice));
ofono_call_settings_create(modem, 0, "qmimodem",
qmi_service_clone(data->voice));
ofono_call_barring_create(modem, 0, "qmimodem",
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 15/23] qmi: location-reporting: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (12 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 14/23] qmi: ussd: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 16/23] qmi: sms: " Denis Kenzior
` (8 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/location-reporting.c | 50 ++++++++-------------------
plugins/gobi.c | 4 +--
2 files changed, 16 insertions(+), 38 deletions(-)
diff --git a/drivers/qmimodem/location-reporting.c b/drivers/qmimodem/location-reporting.c
index 669e9e6fdd41..1c9b9c9c3663 100644
--- a/drivers/qmimodem/location-reporting.c
+++ b/drivers/qmimodem/location-reporting.c
@@ -172,67 +172,46 @@ static void qmi_location_reporting_disable(struct ofono_location_reporting *lr,
}
static void set_event_cb(struct qmi_result *result, void *user_data)
-{
- struct ofono_location_reporting *lr = user_data;
-
- DBG("");
-
- ofono_location_reporting_register(lr);
-}
-
-static void create_pds_cb(struct qmi_service *service, void *user_data)
{
struct ofono_location_reporting *lr = user_data;
struct location_data *data = ofono_location_reporting_get_data(lr);
- struct qmi_param *param;
DBG("");
- if (!service) {
- ofono_error("Failed to request PDS service");
- ofono_location_reporting_remove(lr);
- return;
- }
-
- data->pds = service;
-
qmi_service_register(data->pds, QMI_PDS_EVENT,
event_notify, lr, NULL);
-
qmi_service_register(data->pds, QMI_PDS_STATE_IND,
state_notify, lr, NULL);
- param = qmi_param_new();
-
- qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA, 0x01);
- qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA_DEBUG, 0x00);
-
- if (qmi_service_send(data->pds, QMI_PDS_SET_EVENT, param,
- set_event_cb, lr, NULL) > 0)
- return;
-
- qmi_param_free(param);
-
ofono_location_reporting_register(lr);
}
static int qmi_location_reporting_probe(struct ofono_location_reporting *lr,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *pds = user_data;
struct location_data *data;
+ struct qmi_param *param;
DBG("");
- data = l_new(struct location_data, 1);
+ param = qmi_param_new();
+ qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA, 0x01);
+ qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA_DEBUG, 0x00);
+
+ if (!qmi_service_send(pds, QMI_PDS_SET_EVENT, param,
+ set_event_cb, lr, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(pds);
+ return -EIO;
+ }
+ data = l_new(struct location_data, 1);
+ data->pds = pds;
data->fd = -1;
ofono_location_reporting_set_data(lr, data);
- qmi_service_create_shared(device, QMI_SERVICE_PDS, create_pds_cb, lr,
- NULL);
-
return 0;
}
@@ -245,7 +224,6 @@ static void qmi_location_reporting_remove(struct ofono_location_reporting *lr)
ofono_location_reporting_set_data(lr, NULL);
qmi_service_free(data->pds);
-
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 456a5d2363eb..a0f2fac3dede 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -725,9 +725,9 @@ static void gobi_pre_sim(struct ofono_modem *modem)
ofono_voicecall_create(modem, 0, "qmimodem",
qmi_service_clone(data->voice));
- if (data->features & GOBI_PDS)
+ if (data->features & GOBI_PDS) /* exclusive use, no need to clone */
ofono_location_reporting_create(modem, 0, "qmimodem",
- data->device);
+ l_steal_ptr(data->pds));
}
static void gobi_setup_gprs(struct ofono_modem *modem)
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 16/23] qmi: sms: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (13 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 15/23] qmi: location-reporting: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 17/23] qmi: netreg: " Denis Kenzior
` (7 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/sms.c | 56 +++++++++++-------------------------------
plugins/gobi.c | 3 ++-
2 files changed, 17 insertions(+), 42 deletions(-)
diff --git a/drivers/qmimodem/sms.c b/drivers/qmimodem/sms.c
index 65909c6a71f6..4238665a5e8d 100644
--- a/drivers/qmimodem/sms.c
+++ b/drivers/qmimodem/sms.c
@@ -725,58 +725,33 @@ static void set_event_cb(struct qmi_result *result, void *user_data)
ofono_sms_register(sms);
}
-static void create_wms_cb(struct qmi_service *service, void *user_data)
+static int qmi_sms_probe(struct ofono_sms *sms,
+ unsigned int vendor, void *user_data)
{
- struct ofono_sms *sms = user_data;
- struct sms_data *data = ofono_sms_get_data(sms);
+ struct qmi_service *wms = user_data;
struct qmi_param *param;
+ struct sms_data *data;
DBG("");
- if (!service) {
- ofono_error("Failed to request WMS service");
- ofono_sms_remove(sms);
- return;
- }
+ param = qmi_param_new_uint8(QMI_WMS_PARAM_NEW_MSG_REPORT, 0x01);
- if (!qmi_service_get_version(service, &data->major, &data->minor)) {
- ofono_error("Failed to get WMS service version");
- ofono_sms_remove(sms);
- return;
+ if (!qmi_service_send(wms, QMI_WMS_SET_EVENT, param,
+ set_event_cb, sms, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(wms);
+ return -EIO;
}
- data->wms = service;
-
+ data = l_new(struct sms_data, 1);
+ data->wms = wms;
memset(&data->rd_msg_id, 0, sizeof(data->rd_msg_id));
data->msg_mode = QMI_WMS_MESSAGE_MODE_GSMWCDMA;
-
- qmi_service_register(data->wms, QMI_WMS_EVENT,
- event_notify, sms, NULL);
-
- param = qmi_param_new_uint8(QMI_WMS_PARAM_NEW_MSG_REPORT, 0x01);
-
- if (qmi_service_send(data->wms, QMI_WMS_SET_EVENT, param,
- set_event_cb, sms, NULL) > 0)
- return;
-
- ofono_sms_register(sms);
-}
-
-static int qmi_sms_probe(struct ofono_sms *sms,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct sms_data *data;
-
- DBG("");
-
- data = l_new(struct sms_data, 1);
+ qmi_service_get_version(data->wms, &data->major, &data->minor);
+ qmi_service_register(data->wms, QMI_WMS_EVENT, event_notify, sms, NULL);
ofono_sms_set_data(sms, data);
- qmi_service_create_shared(device, QMI_SERVICE_WMS, create_wms_cb, sms,
- NULL);
-
return 0;
}
@@ -788,11 +763,10 @@ static void qmi_sms_remove(struct ofono_sms *sms)
ofono_sms_set_data(sms, NULL);
- qmi_service_free(data->wms);
-
if (data->msg_list)
l_free(data->msg_list);
+ qmi_service_free(data->wms);
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index a0f2fac3dede..da27930c1e94 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -806,7 +806,8 @@ static void gobi_post_sim(struct ofono_modem *modem)
ofono_radio_settings_create(modem, 0, "qmimodem", data->device);
if (data->features & GOBI_WMS)
- ofono_sms_create(modem, 0, "qmimodem", data->device);
+ ofono_sms_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->wms));
if ((data->features & GOBI_WMS) && (data->features & GOBI_UIM) &&
!ofono_modem_get_boolean(modem, "ForceSimLegacy")) {
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 17/23] qmi: netreg: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (14 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 16/23] qmi: sms: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 18/23] qmi: netmon: " Denis Kenzior
` (6 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
While here, drop all indication registration id members. Explicitly
unregistering from an indication is not required. All indication
registrations will be automatically dropped when the service handle
is freed using qmi_service_free()
---
drivers/qmimodem/network-registration.c | 86 +++++--------------------
plugins/gobi.c | 3 +-
2 files changed, 17 insertions(+), 72 deletions(-)
diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
index 78957a677d2d..c0c9338d1c23 100644
--- a/drivers/qmimodem/network-registration.c
+++ b/drivers/qmimodem/network-registration.c
@@ -31,10 +31,6 @@ struct netreg_data {
int lac;
int cellid;
bool is_roaming;
- uint16_t event_indication_id;
- uint16_t signal_info_indication_id;
- uint16_t system_info_indication_id;
- uint16_t serving_system_indication_id;
};
enum roaming_status {
@@ -587,23 +583,16 @@ static void register_indications_cb(struct qmi_result *result,
ofono_netreg_register(netreg);
- data->event_indication_id =
- qmi_service_register(data->nas, QMI_NAS_EVENT_REPORT,
+ qmi_service_register(data->nas, QMI_NAS_EVENT_REPORT,
event_notify, netreg, NULL);
- data->serving_system_indication_id =
- qmi_service_register(data->nas,
- QMI_NAS_SERVING_SYSTEM_INDICATION,
+ qmi_service_register(data->nas, QMI_NAS_SERVING_SYSTEM_INDICATION,
ss_info_notify, netreg, NULL);
- data->system_info_indication_id =
- qmi_service_register(data->nas,
- QMI_NAS_SYSTEM_INFO_INDICATION,
+ qmi_service_register(data->nas, QMI_NAS_SYSTEM_INFO_INDICATION,
system_info_notify, netreg, NULL);
- data->signal_info_indication_id =
- qmi_service_register(data->nas,
- QMI_NAS_SIGNAL_INFO_INDICATION,
+ qmi_service_register(data->nas, QMI_NAS_SIGNAL_INFO_INDICATION,
signal_info_notify, netreg, NULL);
}
@@ -636,10 +625,10 @@ error:
ofono_netreg_remove(netreg);
}
-static void create_nas_cb(struct qmi_service *service, void *user_data)
+static int qmi_netreg_probe(struct ofono_netreg *netreg,
+ unsigned int vendor, void *user_data)
{
- struct ofono_netreg *netreg = user_data;
- struct netreg_data *data = ofono_netreg_get_data(netreg);
+ struct qmi_service *nas = user_data;
struct qmi_param *param;
static const uint8_t PARAM_REPORT_SIGNAL_STRENGTH = 0x10;
static const uint8_t PARAM_REPORT_RF_INFO = 0x11;
@@ -650,46 +639,28 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
} __attribute__((__packed__)) ss = { .report = 0x01,
.count = 5, .dbm[0] = -55, .dbm[1] = -65,
.dbm[2] = -75, .dbm[3] = -85, .dbm[4] = -95 };
+ struct netreg_data *data;
DBG("");
- if (!service) {
- ofono_error("Failed to request NAS service");
- goto error;
- }
-
- data->nas = service;
-
param = qmi_param_new();
-
qmi_param_append(param, PARAM_REPORT_SIGNAL_STRENGTH, sizeof(ss), &ss);
qmi_param_append_uint8(param, PARAM_REPORT_RF_INFO, 0x01);
- if (qmi_service_send(data->nas, QMI_NAS_SET_EVENT_REPORT, param,
- set_event_report_cb, netreg, NULL) > 0)
- return;
-
- qmi_param_free(param);
-error:
- ofono_netreg_remove(netreg);
-}
-
-static int qmi_netreg_probe(struct ofono_netreg *netreg,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct netreg_data *data;
-
- DBG("");
+ if (!qmi_service_send(nas, QMI_NAS_SET_EVENT_REPORT, param,
+ set_event_report_cb, netreg, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(nas);
+ return -EIO;
+ }
data = l_new(struct netreg_data, 1);
-
+ data->nas = nas;
data->operator.name[0] = '\0';
data->operator.mcc[0] = '\0';
data->operator.mnc[0] = '\0';
data->operator.status = -1;
data->operator.tech = -1;
-
data->current_rat = QMI_NAS_NETWORK_RAT_NO_CHANGE;
data->is_roaming = false;
data->lac = -1;
@@ -697,9 +668,6 @@ static int qmi_netreg_probe(struct ofono_netreg *netreg,
ofono_netreg_set_data(netreg, data);
- qmi_service_create_shared(device, QMI_SERVICE_NAS,
- create_nas_cb, netreg, NULL);
-
return 0;
}
@@ -711,31 +679,7 @@ static void qmi_netreg_remove(struct ofono_netreg *netreg)
ofono_netreg_set_data(netreg, NULL);
- if (data->event_indication_id) {
- qmi_service_unregister(data->nas, data->event_indication_id);
- data->event_indication_id = 0;
- }
-
- if (data->serving_system_indication_id) {
- qmi_service_unregister(data->nas,
- data->serving_system_indication_id);
- data->serving_system_indication_id = 0;
- }
-
- if (data->system_info_indication_id) {
- qmi_service_unregister(data->nas,
- data->system_info_indication_id);
- data->system_info_indication_id = 0;
- }
-
- if (data->signal_info_indication_id) {
- qmi_service_unregister(data->nas,
- data->signal_info_indication_id);
- data->signal_info_indication_id = 0;
- }
-
qmi_service_free(data->nas);
-
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index da27930c1e94..34aa363cf82e 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -829,7 +829,8 @@ static void gobi_post_online(struct ofono_modem *modem)
DBG("%p", modem);
if (data->features & GOBI_NAS) {
- ofono_netreg_create(modem, 0, "qmimodem", data->device);
+ ofono_netreg_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->nas));
ofono_netmon_create(modem, 0, "qmimodem", data->device);
}
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 18/23] qmi: netmon: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (15 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 17/23] qmi: netreg: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 19/23] qmi: lte: " Denis Kenzior
` (5 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/netmon.c | 26 +++-----------------------
plugins/gobi.c | 3 ++-
2 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/qmimodem/netmon.c b/drivers/qmimodem/netmon.c
index f45a9efd6af8..82e0f2a4c737 100644
--- a/drivers/qmimodem/netmon.c
+++ b/drivers/qmimodem/netmon.c
@@ -195,39 +195,19 @@ static void qmi_netmon_request_update(struct ofono_netmon *netmon,
l_free(cbd);
}
-static void create_nas_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_netmon *netmon = user_data;
- struct netmon_data *nmd = ofono_netmon_get_data(netmon);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request NAS service");
- ofono_netmon_remove(netmon);
- return;
- }
-
- nmd->nas = service;
-
- ofono_netmon_register(netmon);
-}
-
static int qmi_netmon_probe(struct ofono_netmon *netmon,
unsigned int vendor, void *user_data)
{
- struct qmi_device *device = user_data;
+ struct qmi_service *nas = user_data;
struct netmon_data *nmd;
DBG("");
nmd = l_new(struct netmon_data, 1);
+ nmd->nas = nas;
ofono_netmon_set_data(netmon, nmd);
- qmi_service_create_shared(device, QMI_SERVICE_NAS,
- create_nas_cb, netmon, NULL);
-
return 0;
}
@@ -240,11 +220,11 @@ static void qmi_netmon_remove(struct ofono_netmon *netmon)
ofono_netmon_set_data(netmon, NULL);
qmi_service_free(nmd->nas);
-
l_free(nmd);
}
static const struct ofono_netmon_driver driver = {
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
.probe = qmi_netmon_probe,
.remove = qmi_netmon_remove,
.request_update = qmi_netmon_request_update,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 34aa363cf82e..8e16e63cd6e2 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -831,7 +831,8 @@ static void gobi_post_online(struct ofono_modem *modem)
if (data->features & GOBI_NAS) {
ofono_netreg_create(modem, 0, "qmimodem",
qmi_service_clone(data->nas));
- ofono_netmon_create(modem, 0, "qmimodem", data->device);
+ ofono_netmon_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->nas));
}
if (data->features & GOBI_VOICE) {
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 19/23] qmi: lte: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (16 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 18/23] qmi: netmon: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 20/23] qmi: gprs-context: " Denis Kenzior
` (4 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/lte.c | 47 ++++++++++--------------------------------
plugins/gobi.c | 4 +++-
2 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/drivers/qmimodem/lte.c b/drivers/qmimodem/lte.c
index 5466eac7c204..d2d1048b5515 100644
--- a/drivers/qmimodem/lte.c
+++ b/drivers/qmimodem/lte.c
@@ -162,10 +162,10 @@ error:
ofono_lte_remove(lte);
}
-static void create_wds_cb(struct qmi_service *service, void *user_data)
+static int qmimodem_lte_probe(struct ofono_lte *lte,
+ unsigned int vendor, void *data)
{
- struct ofono_lte *lte = user_data;
- struct lte_data *ldd = ofono_lte_get_data(lte);
+ struct qmi_service *wds = data;
struct qmi_param *param;
struct {
uint8_t type;
@@ -174,49 +174,25 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
.type = QMI_WDS_PROFILE_TYPE_3GPP,
.family = QMI_WDS_PROFILE_FAMILY_EMBEDDED,
};
+ struct lte_data *ldd;
DBG("");
- if (!service) {
- ofono_error("Failed to request WDS service");
- ofono_lte_remove(lte);
- return;
- }
-
- ldd->wds = service;
-
- /* Query the default profile */
param = qmi_param_new();
-
- /* Profile type */
qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
- /* Get default profile */
- if (qmi_service_send(ldd->wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
- param, get_default_profile_cb, lte, NULL) > 0)
- return;
-
- qmi_param_free(param);
-
- ofono_error("Failed to query default profile");
- ofono_lte_register(lte);
-}
-
-static int qmimodem_lte_probe(struct ofono_lte *lte,
- unsigned int vendor, void *data)
-{
- struct qmi_device *device = data;
- struct lte_data *ldd;
-
- DBG("qmimodem lte probe");
+ if (!qmi_service_send(wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
+ param, get_default_profile_cb, lte, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(wds);
+ return -EIO;
+ }
ldd = l_new(struct lte_data, 1);
+ ldd->wds = wds;
ofono_lte_set_data(lte, ldd);
- qmi_service_create_shared(device, QMI_SERVICE_WDS,
- create_wds_cb, lte, NULL);
-
return 0;
}
@@ -229,7 +205,6 @@ static void qmimodem_lte_remove(struct ofono_lte *lte)
ofono_lte_set_data(lte, NULL);
qmi_service_free(ldd->wds);
-
l_free(ldd);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 8e16e63cd6e2..6d48f0d1bc5b 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -800,7 +800,9 @@ static void gobi_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_lte_create(modem, 0, "qmimodem", data->device);
+ if (data->features & GOBI_WDS)
+ ofono_lte_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->wds));
if (data->features & GOBI_NAS)
ofono_radio_settings_create(modem, 0, "qmimodem", data->device);
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 20/23] qmi: gprs-context: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (17 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 19/23] qmi: lte: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 21/23] qmi: sim: " Denis Kenzior
` (3 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/gprs-context.c | 70 +++++++++++++--------------------
plugins/gobi.c | 4 +-
2 files changed, 29 insertions(+), 45 deletions(-)
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 625fd0b8f193..aae058f35a9b 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -22,7 +22,6 @@
struct gprs_context_data {
struct qmi_service *wds;
- struct qmi_device *dev;
unsigned int active_context;
uint32_t pkt_handle;
uint8_t mux_id;
@@ -480,9 +479,10 @@ static void bind_mux_data_port_cb(struct qmi_result *result, void *user_data)
}
}
-static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
+static int qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc,
+ struct qmi_service *wds,
+ uint8_t mux_id)
{
- struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
struct ofono_modem *modem = ofono_gprs_context_get_modem(gc);
struct qmi_param *param;
const char *interface_number;
@@ -496,7 +496,7 @@ static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
bus = ofono_modem_get_string(modem, "Bus");
if (!bus) {
ofono_error("%s: Missing 'Bus'", ofono_modem_get_path(modem));
- goto error;
+ return -EINVAL;
}
if (!strcmp(bus, "pcie"))
@@ -508,7 +508,7 @@ static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
else {
ofono_error("%s: Invalid 'Bus' value",
ofono_modem_get_path(modem));
- goto error;
+ return -ENOTSUP;
}
switch (endpoint_info.endpoint_type) {
@@ -528,68 +528,54 @@ static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
ofono_error("%s: Missing or invalid 'InterfaceNumber'",
ofono_modem_get_path(modem));
- /* Fall through */
+ return -EINVAL;
default:
- goto error;
+ return -ENOTSUP;
}
DBG("interface_number: %d", endpoint_info.interface_number);
- DBG("mux_id: %hhx", data->mux_id);
+ DBG("mux_id: %hhx", mux_id);
param = qmi_param_new();
qmi_param_append(param, 0x10, sizeof(endpoint_info), &endpoint_info);
- qmi_param_append_uint8(param, 0x11, data->mux_id);
+ qmi_param_append_uint8(param, 0x11, mux_id);
qmi_param_append_uint32(param, 0x13, QMI_WDS_CLIENT_TYPE_TETHERED);
- if (qmi_service_send(data->wds, QMI_WDS_BIND_MUX_DATA_PORT, param,
+ if (qmi_service_send(wds, QMI_WDS_BIND_MUX_DATA_PORT, param,
bind_mux_data_port_cb, gc, NULL) > 0)
- return;
+ return 0;
qmi_param_free(param);
-error:
- ofono_error("Failed to BIND_MUX_DATA_PORT");
- ofono_gprs_context_remove(gc);
+ return -EIO;
}
-static void create_wds_cb(struct qmi_service *service, void *user_data)
+static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
+ unsigned int vendor, void *user_data)
{
- struct ofono_gprs_context *gc = user_data;
- struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
+ struct qmi_service *wds = user_data;
+ struct gprs_context_data *data;
DBG("");
- if (!service) {
- ofono_error("Failed to request WDS service");
- ofono_gprs_context_remove(gc);
- return;
+ if (vendor) {
+ int r = qmi_gprs_context_bind_mux(gc, wds, vendor);
+
+ if (r < 0) {
+ qmi_service_free(wds);
+ return r;
+ }
}
- data->wds = service;
+ data = l_new(struct gprs_context_data, 1);
+ data->wds = wds;
+ data->mux_id = vendor;
qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS,
pkt_status_notify, gc, NULL);
- if (data->mux_id)
- qmi_gprs_context_bind_mux(gc);
-}
-
-static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct gprs_context_data *data;
-
- DBG("");
-
- data = l_new(struct gprs_context_data, 1);
-
ofono_gprs_context_set_data(gc, data);
- data->dev = device;
- data->mux_id = vendor;
- qmi_service_create_shared(data->dev, QMI_SERVICE_WDS, create_wds_cb, gc,
- NULL);
return 0;
}
@@ -601,9 +587,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc)
ofono_gprs_context_set_data(gc, NULL);
- if (data->wds)
- qmi_service_free(data->wds);
-
+ qmi_service_free(data->wds);
l_free(data);
}
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 6d48f0d1bc5b..65629e92ba09 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -752,7 +752,7 @@ static void gobi_setup_gprs(struct ofono_modem *modem)
interface = ofono_modem_get_string(modem, "NetworkInterface");
gc = ofono_gprs_context_create(modem, 0, "qmimodem",
- data->device);
+ qmi_service_clone(data->wds));
if (!gc) {
ofono_warn("Unable to create gprs-context for: %s",
ofono_modem_get_path(modem));
@@ -778,7 +778,7 @@ static void gobi_setup_gprs(struct ofono_modem *modem)
mux_id = ofono_modem_get_integer(modem, buf);
gc = ofono_gprs_context_create(modem, mux_id, "qmimodem",
- data->device);
+ qmi_service_clone(data->wds));
if (!gc) {
ofono_warn("gprs-context creation failed for [%d] %s",
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 21/23] qmi: sim: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (18 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 20/23] qmi: gprs-context: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 22/23] qmi: gprs: " Denis Kenzior
` (2 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Use qmi_device_get_service and qmi_device_add_service_watch
---
drivers/qmimodem/sim.c | 96 +++++++++---------------------------------
plugins/gobi.c | 4 +-
2 files changed, 23 insertions(+), 77 deletions(-)
diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c
index 67925239f2b5..876274fa87b4 100644
--- a/drivers/qmimodem/sim.c
+++ b/drivers/qmimodem/sim.c
@@ -44,14 +44,12 @@ struct sim_status {
};
struct sim_data {
- struct qmi_device *qmi_dev;
struct qmi_service *dms;
struct qmi_service *uim;
uint32_t event_mask;
uint8_t app_type;
uint32_t retry_count;
struct l_timeout *retry_timer;
- uint16_t card_status_indication_id;
};
static int create_fileid_data(uint8_t app_type, int fileid,
@@ -827,9 +825,7 @@ static void event_registration_cb(struct qmi_result *result, void *user_data)
DBG("event mask 0x%04x", data->event_mask);
if (data->event_mask & 0x0001) {
- data->card_status_indication_id =
- qmi_service_register(data->uim,
- QMI_UIM_GET_CARD_STATUS_EVENT,
+ qmi_service_register(data->uim, QMI_UIM_GET_CARD_STATUS_EVENT,
card_status_notify, sim, NULL);
}
@@ -841,68 +837,32 @@ error:
ofono_sim_remove(sim);
}
-static void create_uim_cb(struct qmi_service *service, void *user_data)
+static int qmi_sim_probev(struct ofono_sim *sim,
+ unsigned int vendor, va_list args)
{
- struct ofono_sim *sim = user_data;
- struct sim_data *data = ofono_sim_get_data(sim);
- struct qmi_param *param;
- uint32_t mask = 0x0003;
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request UIM service");
- goto error;
- }
-
- data->uim = service;
-
- param = qmi_param_new_uint32(QMI_UIM_PARAM_EVENT_MASK, mask);
-
- if (qmi_service_send(data->uim, QMI_UIM_EVENT_REGISTRATION, param,
- event_registration_cb, sim, NULL) > 0)
- return;
-
-error:
- ofono_sim_remove(sim);
-}
-
-static void create_dms_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_sim *sim = user_data;
- struct sim_data *data = ofono_sim_get_data(sim);
+ struct qmi_service *dms = va_arg(args, struct qmi_service *);
+ struct qmi_service *uim = va_arg(args, struct qmi_service *);
+ static const uint32_t mask = 0x0003;
+ struct qmi_param *param =
+ qmi_param_new_uint32(QMI_UIM_PARAM_EVENT_MASK, mask);
+ struct sim_data *data;
DBG("");
- if (!service) {
- ofono_error("Failed to request DMS service");
- ofono_sim_remove(sim);
- return;
+ if (!qmi_service_send(uim, QMI_UIM_EVENT_REGISTRATION, param,
+ event_registration_cb, sim, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(dms);
+ qmi_service_free(uim);
+ return -EIO;
}
- data->dms = service;
-
- qmi_service_create_shared(data->qmi_dev, QMI_SERVICE_UIM, create_uim_cb,
- sim, NULL);
-}
-
-static int qmi_sim_probe(struct ofono_sim *sim,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct sim_data *data;
-
- DBG("");
-
data = l_new(struct sim_data, 1);
-
- data->qmi_dev = device;
+ data->uim = uim;
+ data->dms = dms;
ofono_sim_set_data(sim, data);
- qmi_service_create_shared(device, QMI_SERVICE_DMS,
- create_dms_cb, sim, NULL);
-
return 0;
}
@@ -915,29 +875,13 @@ static void qmi_sim_remove(struct ofono_sim *sim)
ofono_sim_set_data(sim, NULL);
l_timeout_remove(data->retry_timer);
- data->retry_timer = NULL;
-
- if (data->uim) {
- if (data->card_status_indication_id) {
- qmi_service_unregister(data->uim,
- data->card_status_indication_id);
- data->card_status_indication_id = 0;
- }
-
- qmi_service_free(data->uim);
- data->uim = NULL;
- }
-
- if (data->dms) {
- qmi_service_free(data->dms);
- data->dms = NULL;
- }
-
+ qmi_service_free(data->uim);
+ qmi_service_free(data->dms);
l_free(data);
}
static const struct ofono_sim_driver driver = {
- .probe = qmi_sim_probe,
+ .probev = qmi_sim_probev,
.remove = qmi_sim_remove,
.read_file_info = qmi_read_attributes,
.read_file_transparent = qmi_read_transparent,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 65629e92ba09..7ded86c52b96 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -716,7 +716,9 @@ static void gobi_pre_sim(struct ofono_modem *modem)
ofono_devinfo_create(modem, 0, "qmimodem", qmi_service_clone(data->dms));
if ((data->features & GOBI_UIM) && !legacy)
- ofono_sim_create(modem, 0, "qmimodem", data->device);
+ ofono_sim_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->dms),
+ qmi_service_clone(data->uim));
else /* DMS always available */
ofono_sim_create(modem, 0, "qmimodem_legacy",
qmi_service_clone(data->dms));
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 22/23] qmi: gprs: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (19 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 21/23] qmi: sim: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 23/23] qmi: radio-settings: " Denis Kenzior
2024-06-14 15:10 ` [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation patchwork-bot+ofono
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/gprs.c | 85 +++++++++--------------------------------
plugins/gobi.c | 4 +-
2 files changed, 22 insertions(+), 67 deletions(-)
diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c
index 03ee377e8916..da7ad63c49cb 100644
--- a/drivers/qmimodem/gprs.c
+++ b/drivers/qmimodem/gprs.c
@@ -21,7 +21,6 @@
#include "util.h"
struct gprs_data {
- struct qmi_device *dev;
struct qmi_service *nas;
struct qmi_service *wds;
unsigned int default_profile;
@@ -405,9 +404,12 @@ error:
ofono_gprs_remove(gprs);
}
-static int get_default_profile_number_request(struct ofono_gprs *gprs)
+static int qmi_gprs_probev(struct ofono_gprs *gprs,
+ unsigned int vendor, va_list args)
{
- struct gprs_data *data = ofono_gprs_get_data(gprs);
+ struct qmi_service *wds = va_arg(args, struct qmi_service *);
+ struct qmi_service *nas = va_arg(args, struct qmi_service *);
+ struct gprs_data *data;
struct {
uint8_t type;
uint8_t family;
@@ -423,77 +425,29 @@ static int get_default_profile_number_request(struct ofono_gprs *gprs)
*/
qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
- if (qmi_service_send(data->wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
+ if (!qmi_service_send(wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
param, get_default_profile_number_cb,
- gprs, NULL) > 0)
- return 0;
-
- qmi_param_free(param);
- return -EIO;
-}
-
-static void create_wds_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_gprs *gprs = user_data;
- struct gprs_data *data = ofono_gprs_get_data(gprs);
+ gprs, NULL)) {
+ qmi_param_free(param);
+ qmi_service_free(nas);
+ qmi_service_free(wds);
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request WDS service");
- goto error;
+ return -EIO;
}
- data->wds = service;
- qmi_service_register(data->wds, QMI_WDS_EVENT_REPORT,
- event_report_notify, gprs, NULL);
- qmi_service_register(data->wds, QMI_WDS_PROFILE_CHANGED,
- profile_changed_notify, gprs, NULL);
-
- if (get_default_profile_number_request(gprs) >= 0)
- return;
-error:
- ofono_gprs_remove(gprs);
-}
-
-static void create_nas_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_gprs *gprs = user_data;
- struct gprs_data *data = ofono_gprs_get_data(gprs);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request NAS service");
- ofono_gprs_remove(gprs);
- return;
- }
+ data = l_new(struct gprs_data, 1);
+ data->wds = wds;
+ data->nas = nas;
- data->nas = service;
qmi_service_register(data->nas, QMI_NAS_SERVING_SYSTEM_INDICATION,
ss_info_notify, gprs, NULL);
-
- qmi_service_create_shared(data->dev, QMI_SERVICE_WDS,
- create_wds_cb, gprs, NULL);
-}
-
-static int qmi_gprs_probe(struct ofono_gprs *gprs,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
- struct gprs_data *data;
-
- DBG("");
-
- data = l_new(struct gprs_data, 1);
+ qmi_service_register(data->wds, QMI_WDS_EVENT_REPORT,
+ event_report_notify, gprs, NULL);
+ qmi_service_register(data->wds, QMI_WDS_PROFILE_CHANGED,
+ profile_changed_notify, gprs, NULL);
ofono_gprs_set_data(gprs, data);
- data->dev = device;
-
- qmi_service_create_shared(device, QMI_SERVICE_NAS,
- create_nas_cb, gprs, NULL);
-
return 0;
}
@@ -507,12 +461,11 @@ static void qmi_gprs_remove(struct ofono_gprs *gprs)
qmi_service_free(data->wds);
qmi_service_free(data->nas);
-
l_free(data);
}
static const struct ofono_gprs_driver driver = {
- .probe = qmi_gprs_probe,
+ .probev = qmi_gprs_probev,
.remove = qmi_gprs_remove,
.set_attached = qmi_set_attached,
.attached_status = qmi_attached_status,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 7ded86c52b96..1a866490d41c 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -742,7 +742,9 @@ static void gobi_setup_gprs(struct ofono_modem *modem)
char buf[256];
int i;
- gprs = ofono_gprs_create(modem, 0, "qmimodem", data->device);
+ gprs = ofono_gprs_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->wds),
+ qmi_service_clone(data->nas));
if (!gprs) {
ofono_warn("Unable to create gprs for: %s",
ofono_modem_get_path(modem));
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH v2 23/23] qmi: radio-settings: Drop use of qmi_service_create_shared
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (20 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 22/23] qmi: gprs: " Denis Kenzior
@ 2024-06-13 21:41 ` Denis Kenzior
2024-06-14 15:10 ` [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation patchwork-bot+ofono
22 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2024-06-13 21:41 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
drivers/qmimodem/radio-settings.c | 56 ++++++-------------------------
plugins/gobi.c | 4 ++-
2 files changed, 13 insertions(+), 47 deletions(-)
diff --git a/drivers/qmimodem/radio-settings.c b/drivers/qmimodem/radio-settings.c
index 2e428b9d0c2e..8463c84bf1ed 100644
--- a/drivers/qmimodem/radio-settings.c
+++ b/drivers/qmimodem/radio-settings.c
@@ -198,59 +198,22 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
}
-static void create_dms_cb(struct qmi_service *service, void *user_data)
+static int qmi_radio_settings_probev(struct ofono_radio_settings *rs,
+ unsigned int vendor, va_list args)
{
- struct ofono_radio_settings *rs = user_data;
- struct settings_data *data = ofono_radio_settings_get_data(rs);
-
- DBG("");
-
- if (!service)
- return;
-
- data->dms = service;
-}
-
-static void create_nas_cb(struct qmi_service *service, void *user_data)
-{
- struct ofono_radio_settings *rs = user_data;
- struct settings_data *data = ofono_radio_settings_get_data(rs);
-
- DBG("");
-
- if (!service) {
- ofono_error("Failed to request NAS service");
- ofono_radio_settings_remove(rs);
- return;
- }
-
- if (!qmi_service_get_version(service, &data->major, &data->minor)) {
- ofono_error("Failed to get NAS service version");
- ofono_radio_settings_remove(rs);
- return;
- }
-
- data->nas = service;
-
- ofono_radio_settings_register(rs);
-}
-
-static int qmi_radio_settings_probe(struct ofono_radio_settings *rs,
- unsigned int vendor, void *user_data)
-{
- struct qmi_device *device = user_data;
+ struct qmi_service *dms = va_arg(args, struct qmi_service *);
+ struct qmi_service *nas = va_arg(args, struct qmi_service *);
struct settings_data *data;
DBG("");
data = l_new(struct settings_data, 1);
+ data->dms = dms;
+ data->nas = nas;
- ofono_radio_settings_set_data(rs, data);
+ qmi_service_get_version(data->nas, &data->major, &data->minor);
- qmi_service_create_shared(device, QMI_SERVICE_DMS,
- create_dms_cb, rs, NULL);
- qmi_service_create_shared(device, QMI_SERVICE_NAS,
- create_nas_cb, rs, NULL);
+ ofono_radio_settings_set_data(rs, data);
return 0;
}
@@ -270,7 +233,8 @@ static void qmi_radio_settings_remove(struct ofono_radio_settings *rs)
}
static const struct ofono_radio_settings_driver driver = {
- .probe = qmi_radio_settings_probe,
+ .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
+ .probev = qmi_radio_settings_probev,
.remove = qmi_radio_settings_remove,
.set_rat_mode = qmi_set_rat_mode,
.query_rat_mode = qmi_query_rat_mode,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 1a866490d41c..5402bedcc22e 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -809,7 +809,9 @@ static void gobi_post_sim(struct ofono_modem *modem)
qmi_service_clone(data->wds));
if (data->features & GOBI_NAS)
- ofono_radio_settings_create(modem, 0, "qmimodem", data->device);
+ ofono_radio_settings_create(modem, 0, "qmimodem",
+ qmi_service_clone(data->dms),
+ qmi_service_clone(data->nas));
if (data->features & GOBI_WMS)
ofono_sms_create(modem, 0, "qmimodem",
--
2.45.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
` (21 preceding siblings ...)
2024-06-13 21:41 ` [PATCH v2 23/23] qmi: radio-settings: " Denis Kenzior
@ 2024-06-14 15:10 ` patchwork-bot+ofono
22 siblings, 0 replies; 24+ messages in thread
From: patchwork-bot+ofono @ 2024-06-14 15:10 UTC (permalink / raw)
To: Denis Kenzior; +Cc: ofono
Hello:
This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:
On Thu, 13 Jun 2024 16:41:10 -0500 you wrote:
> These atoms do not exist in the current qmimodem driver. Remove them
> until they're added back in.
> ---
> plugins/gobi.c | 26 +++-----------------------
> 1 file changed, 3 insertions(+), 23 deletions(-)
Here is the summary with links:
- [v2,01/23] gobi: Remove phonebook and stk atom creation
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=540689ac89b5
- [v2,02/23] qmi: lookup shared family directly by type
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=eda7b48d5737
- [v2,03/23] core: allow multiple args in atom constructors
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=27c8b1d178c3
- [v2,04/23] unit: Update unit tests to the new API
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=c7ece29ab1f5
- [v2,05/23] core: Support register on probe flag
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=063856a2ba93
- [v2,06/23] qmi: introduce qmi_service_clone
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=c6226a486eb1
- [v2,07/23] gobi: request needed services at .enable()
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=67a899089ac8
- [v2,08/23] qmi: devinfo: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=97dd4a15230d
- [v2,09/23] qmi: sim-legacy: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=ab6c6d22a7b9
- [v2,10/23] qmi: voicecall: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=b4d86ddb4bb1
- [v2,11/23] qmi: call-barring: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=5ce6c2a31ed3
- [v2,12/23] qmi: call-forwarding: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=bb9f9390831b
- [v2,13/23] qmi: call-settings: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=c43de054332a
- [v2,14/23] qmi: ussd: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=d627f3d6b991
- [v2,15/23] qmi: location-reporting: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=0f2341fe9753
- [v2,16/23] qmi: sms: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=b5c96dee90f6
- [v2,17/23] qmi: netreg: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=2af37b3a96c3
- [v2,18/23] qmi: netmon: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=75dd97480610
- [v2,19/23] qmi: lte: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=48230640815e
- [v2,20/23] qmi: gprs-context: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=841b2e5d3f8d
- [v2,21/23] qmi: sim: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=c571d73dc1c7
- [v2,22/23] qmi: gprs: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=607e7ef2f89e
- [v2,23/23] qmi: radio-settings: Drop use of qmi_service_create_shared
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=1e4b61884a6f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 24+ messages in thread