Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10be142e authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

diag: Clean diagfwd code



Remove diagfwd_bridge_init and _exit functions and call mhi_init
and _exit functions directly from mhi registration function
instead. Refactor other parts for more readability and readiness
of USB bridge implementation.

Change-Id: I8255d00da14137318b2135eb8e5f59ee49aa8c89
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent b44b1cf6
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
@@ -1136,15 +1136,6 @@ void diag_remote_exit(void)
{
}

int diagfwd_bridge_init(void)
{
	return 0;
}

void diagfwd_bridge_exit(void)
{
}

uint16_t diag_get_remote_device_mask(void)
{
	return 0;
@@ -4244,12 +4235,10 @@ static int __init diagchar_init(void)
	diagchar_cleanup();
	diag_mux_exit();
	diagfwd_peripheral_exit();
	diagfwd_bridge_exit();
	diagfwd_exit();
	diagfwd_cntl_exit();
	diag_dci_exit();
	diag_masks_exit();
	diag_remote_exit();
	return ret;

}
@@ -4265,7 +4254,9 @@ static void diagchar_exit(void)
	diag_dci_exit();
	diag_masks_exit();
	diag_md_session_exit();
	diag_remote_exit();
#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
	diag_unregister_mhi();
#endif
	diag_debugfs_cleanup();
	diagchar_cleanup();
	pr_info("done diagchar exit\n");
+1 −28
Original line number Diff line number Diff line
@@ -20,19 +20,13 @@
#include <linux/platform_device.h>
#include "diag_mux.h"
#include "diagfwd_bridge.h"
#ifdef USB_QCOM_DIAG_BRIDGE
#ifdef CONFIG_USB_QCOM_DIAG_BRIDGE
#include "diagfwd_hsic.h"
#endif
#include "diagfwd_mhi.h"
#include "diag_dci.h"
#include "diag_ipc_logging.h"

#ifdef CONFIG_MHI_BUS
#define diag_mdm_init		diag_mhi_init
#else
#define diag_mdm_init		diag_hsic_init
#endif

#define BRIDGE_TO_MUX(x)	(x + DIAG_MUX_BRIDGE_BASE)

struct diagfwd_bridge_info bridge_info[NUM_REMOTE_DEV] = {
@@ -237,27 +231,6 @@ int diag_remote_dev_write_done(int id, unsigned char *buf, int len, int ctxt)
	return err;
}

int diagfwd_bridge_init(void)
{
	int err = 0;

	err = diag_mdm_init();
	if (err)
		goto fail;
	return 0;

fail:
	pr_err("diag: Unable to initialze diagfwd bridge, err: %d\n", err);
	return err;
}

void diagfwd_bridge_exit(void)
{
	#ifdef USB_QCOM_DIAG_BRIDGE
	diag_hsic_exit();
	#endif
}

int diagfwd_bridge_close(int id)
{
	if (id < 0 || id >= NUM_REMOTE_DEV)
+1 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -51,8 +51,6 @@ struct diagfwd_bridge_info {
};

extern struct diagfwd_bridge_info bridge_info[NUM_REMOTE_DEV];
int diagfwd_bridge_init(void);
void diagfwd_bridge_exit(void);
int diagfwd_bridge_close(int id);
int diagfwd_bridge_write(int id, unsigned char *buf, int len);
uint16_t diag_get_remote_device_mask(void);
+9 −5
Original line number Diff line number Diff line
@@ -764,17 +764,21 @@ void diag_register_with_mhi(void)
	int ret = 0;

	ret = diag_remote_init();
	if (ret) {
		diag_remote_exit();
	if (ret)
		return;
	}

	ret = diagfwd_bridge_init();
	ret = diag_mhi_init();
	if (ret) {
		diagfwd_bridge_exit();
		diag_remote_exit();
		return;
	}

	mhi_driver_register(&diag_mhi_driver);
}

void diag_unregister_mhi(void)
{
	mhi_driver_unregister(&diag_mhi_driver);
	diag_mhi_exit();
	diag_remote_exit();
}
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -83,4 +83,5 @@ extern struct diag_mhi_info diag_mhi[NUM_MHI_DEV];
int diag_mhi_init(void);
void diag_mhi_exit(void);
void diag_register_with_mhi(void);
void diag_unregister_mhi(void);
#endif