net: openthread: Remove deprecated APIs

Remove OpenThread APIs that were deprecated in Zephyr 4.2.0.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
diff --git a/include/zephyr/net/openthread.h b/include/zephyr/net/openthread.h
index 0fc6c93..fc9efb7 100644
--- a/include/zephyr/net/openthread.h
+++ b/include/zephyr/net/openthread.h
@@ -44,11 +44,6 @@
  * @brief OpenThread l2 private data.
  */
 struct openthread_context {
-	/** @deprecated Pointer to OpenThread stack instance. This is deprecated and will be removed
-	 * in a future release. This field must not be used anymore.
-	 */
-	__deprecated otInstance *instance;
-
 	/** Pointer to OpenThread network interface */
 	struct net_if *iface;
 
@@ -63,88 +58,11 @@
 
 	/** Array for storing net_pkt for OpenThread internal usage */
 	struct pkt_list_elem pkt_list[CONFIG_OPENTHREAD_PKT_LIST_SIZE];
-
-	/** @deprecated A mutex to protect API calls from being preempted. This is deprecated and
-	 * will be removed in a future release. This field must not be used anymore.
-	 */
-	__deprecated struct k_mutex api_lock;
-
-	/** @deprecated A work queue for all OpenThread activity. This is deprecated and will be
-	 * removed in a future release. This field must not be used anymore.
-	 */
-	__deprecated struct k_work_q work_q;
-
-	/** @deprecated Work object for OpenThread internal usage. This is deprecated and will be
-	 * removed in a future release. This field must not be used anymore.
-	 */
-	__deprecated struct k_work api_work;
-
-	/** @deprecated A list for state change callbacks. This is deprecated and will be removed in
-	 * a future release.
-	 */
-	sys_slist_t state_change_cbs;
 };
 /**
  * INTERNAL_HIDDEN @endcond
  */
 
-/** OpenThread state change callback  */
-
-/**
- * @deprecated use @ref openthread_state_changed_callback instead.
- *
- * @brief OpenThread state change callback structure
- *
- * Used to register a callback in the callback list. As many
- * callbacks as needed can be added as long as each of them
- * are unique pointers of struct openthread_state_changed_cb.
- * Beware such structure should not be allocated on stack.
- */
-struct openthread_state_changed_cb {
-	/**
-	 * @brief Callback for notifying configuration or state changes.
-	 *
-	 * @param flags as per OpenThread otStateChangedCallback() aFlags parameter.
-	 *        See https://openthread.io/reference/group/api-instance#otstatechangedcallback
-	 * @param ot_context the OpenThread context the callback is registered with.
-	 * @param user_data Data to pass to the callback.
-	 */
-	void (*state_changed_cb)(otChangedFlags flags, struct openthread_context *ot_context,
-				 void *user_data);
-
-	/** User data if required */
-	void *user_data;
-
-	/**
-	 * Internally used field for list handling
-	 *  - user must not directly modify
-	 */
-	sys_snode_t node;
-};
-
-/**
- * @deprecated use @ref openthread_state_changed_callback_register instead.
- *
- * @brief Registers callbacks which will be called when certain configuration
- * or state changes occur within OpenThread.
- *
- * @param ot_context the OpenThread context to register the callback with.
- * @param cb callback struct to register.
- */
-__deprecated int openthread_state_changed_cb_register(struct openthread_context *ot_context,
-						      struct openthread_state_changed_cb *cb);
-
-/**
- * @deprecated use @ref openthread_state_changed_callback_unregister instead.
- *
- * @brief Unregisters OpenThread configuration or state changed callbacks.
- *
- * @param ot_context the OpenThread context to unregister the callback from.
- * @param cb callback struct to unregister.
- */
-__deprecated int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
-							struct openthread_state_changed_cb *cb);
-
 /**
  * @brief Get pointer to default OpenThread context.
  *
@@ -153,56 +71,6 @@
  */
 struct openthread_context *openthread_get_default_context(void);
 
-/**
- * @deprecated use @ref openthread_run instead.
- *
- * @brief Starts the OpenThread network.
- *
- * @details Depends on active settings: it uses stored network configuration,
- * start joining procedure or uses default network configuration. Additionally
- * when the device is MTD, it sets the SED mode to properly attach the network.
- *
- * @param ot_context
- */
-__deprecated int openthread_start(struct openthread_context *ot_context);
-
-/**
- * @deprecated use @ref openthread_mutex_lock.
- *
- * @brief Lock internal mutex before accessing OT API.
- *
- * @details OpenThread API is not thread-safe, therefore before accessing any
- * API function, it's needed to lock the internal mutex, to prevent the
- * OpenThread thread from preempting the API call.
- *
- * @param ot_context Context to lock.
- */
-__deprecated void openthread_api_mutex_lock(struct openthread_context *ot_context);
-
-/**
- * @deprecated use @ref openthread_mutex_try_lock instead.
- *
- * @brief Try to lock internal mutex before accessing OT API.
- *
- * @details This function behaves like openthread_api_mutex_lock() provided that
- * the internal mutex is unlocked. Otherwise, it exists immediately and returns
- * a negative value.
- *
- * @param ot_context Context to lock.
- * @retval 0  On success.
- * @retval <0 On failure.
- */
-__deprecated int openthread_api_mutex_try_lock(struct openthread_context *ot_context);
-
-/**
- * @deprecated use @ref openthread_mutex_unlock instead.
- *
- * @brief Unlock internal mutex after accessing OT API.
- *
- * @param ot_context Context to unlock.
- */
-__deprecated void openthread_api_mutex_unlock(struct openthread_context *ot_context);
-
 /** @cond INTERNAL_HIDDEN */
 
 #define OPENTHREAD_L2_CTX_TYPE struct openthread_context
diff --git a/subsys/net/l2/openthread/openthread.c b/subsys/net/l2/openthread/openthread.c
index d61af93..2abc7de 100644
--- a/subsys/net/l2/openthread/openthread.c
+++ b/subsys/net/l2/openthread/openthread.c
@@ -84,7 +84,6 @@
 static void ot_l2_state_changed_handler(uint32_t flags, void *context)
 {
 	struct openthread_context *ot_context = context;
-	struct openthread_state_changed_cb *entry, *next;
 
 #if defined(CONFIG_OPENTHREAD_INTERFACE_EARLY_UP)
 	bool is_up = otIp6IsEnabled(openthread_get_default_instance());
@@ -140,12 +139,6 @@
 	}
 
 #endif /* CONFIG_OPENTHREAD_NAT64_TRANSLATOR */
-
-	SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&ot_context->state_change_cbs, entry, next, node) {
-		if (entry->state_changed_cb != NULL) {
-			entry->state_changed_cb(flags, ot_context, entry->user_data);
-		}
-	}
 }
 
 static void ot_receive_handler(otMessage *message, void *context)
@@ -356,10 +349,6 @@
 		openthread_border_router_init(ot_l2_context);
 #endif /* CONFIG_OPENTHREAD_ZEPHYR_BORDER_ROUTER */
 
-		/* To keep backward compatibility use the additional state change callback list from
-		 * the ot l2 context and register the callback to the openthread module.
-		 */
-		sys_slist_init(&ot_l2_context->state_change_cbs);
 		openthread_state_changed_callback_register(&ot_l2_state_changed_cb);
 	}
 
@@ -426,76 +415,4 @@
 	return ot_context;
 }
 
-/* Keep deprecated functions and forward them to the OpenThread platform module */
-int openthread_start(struct openthread_context *ot_context)
-{
-	ARG_UNUSED(ot_context);
-
-	return openthread_run();
-}
-
-void openthread_api_mutex_lock(struct openthread_context *ot_context)
-{
-	/* The mutex is managed internally by the OpenThread module */
-	ARG_UNUSED(ot_context);
-
-	openthread_mutex_lock();
-}
-
-int openthread_api_mutex_try_lock(struct openthread_context *ot_context)
-{
-	/* The mutex is managed internally by the OpenThread module */
-	ARG_UNUSED(ot_context);
-
-	return openthread_mutex_try_lock();
-}
-
-void openthread_api_mutex_unlock(struct openthread_context *ot_context)
-{
-	/* The mutex is managed internally by the OpenThread module */
-	ARG_UNUSED(ot_context);
-
-	openthread_mutex_unlock();
-}
-
-/* Keep deprecated state change callback registration functions to keep backward compatibility.
- * The callbacks that are registered using these functions are run by the OpenThread module
- * as one of the platform callback. However, they will be not supported in the future after
- * deprecation period, so it is recommended to switch to
- * openthread_state_change_callback_register() instead.
- */
-int openthread_state_changed_cb_register(struct openthread_context *ot_context,
-					 struct openthread_state_changed_cb *cb)
-{
-	CHECKIF(cb == NULL || cb->state_changed_cb == NULL) {
-		return -EINVAL;
-	}
-
-	openthread_mutex_lock();
-	sys_slist_append(&ot_context->state_change_cbs, &cb->node);
-	openthread_mutex_unlock();
-
-	return 0;
-}
-
-int openthread_state_changed_cb_unregister(struct openthread_context *ot_context,
-					   struct openthread_state_changed_cb *cb)
-{
-	bool removed;
-
-	CHECKIF(cb == NULL) {
-		return -EINVAL;
-	}
-
-	openthread_mutex_lock();
-	removed = sys_slist_find_and_remove(&ot_context->state_change_cbs, &cb->node);
-	openthread_mutex_unlock();
-
-	if (!removed) {
-		return -EALREADY;
-	}
-
-	return 0;
-}
-
 NET_L2_INIT(OPENTHREAD_L2, openthread_recv, openthread_send, openthread_enable, openthread_flags);