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

Commit 6996c3c1 authored by Jack Pham's avatar Jack Pham
Browse files

usb: gadget: Add snapshot of USB DIAG function driver



This change adds USB DIAG function driver to support diagnostics
functionality with USB transport. This snapshot is taken as of
msm-4.19 commit 104eef6e1fe8 ("platform: msm: Remove unused local count
variable").

Change-Id: Id5216e3de9b2edb8d1fa79d0b53e172fcb451ec6
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent e6c9811c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -216,6 +216,9 @@ config USB_F_PRINTER
config USB_F_TCM
	tristate

config USB_F_DIAG
	tristate

config USB_F_ACC
	tristate

@@ -513,6 +516,16 @@ config USB_CONFIGFS_F_TCM
	  Both protocols can work on USB2.0 and USB3.0.
	  UAS utilizes the USB 3.0 feature called streams support.

config USB_CONFIGFS_F_DIAG
	tristate "USB Diag function"
	select USB_F_DIAG
	depends on USB_CONFIGFS
	help
	  Diag function driver enables support for diagnostics service over USB.
	  Diagnostics application running on Host receives  stream of log data
	  over USB. Applications can also send commands to diagnostics client
	  running on device.

choice
	tristate "USB Gadget precomposed configurations"
	default USB_ETH
+2 −0
Original line number Diff line number Diff line
@@ -54,3 +54,5 @@ usb_f_accessory-y := f_accessory.o
obj-$(CONFIG_USB_F_ACC)		+= usb_f_accessory.o
usb_f_audio_source-y		:= f_audio_source.o
obj-$(CONFIG_USB_F_AUDIO_SRC)	+= usb_f_audio_source.o
usb_f_diag-y			:= f_diag.o
obj-$(CONFIG_USB_F_DIAG)	+= usb_f_diag.o
+1093 −0

File added.

Preview size limit exceeded, changes collapsed.

+72 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2008-2010, 2012-2014, The Linux Foundation.
 * All rights reserved.
 */

#ifndef _DRIVERS_USB_DIAG_H_
#define _DRIVERS_USB_DIAG_H_

#include <linux/err.h>

#define DIAG_LEGACY		"diag"
#define DIAG_MDM		"diag_mdm"
#define DIAG_QSC		"diag_qsc"
#define DIAG_MDM2		"diag_mdm2"

#define USB_DIAG_CONNECT	0
#define USB_DIAG_DISCONNECT	1
#define USB_DIAG_WRITE_DONE	2
#define USB_DIAG_READ_DONE	3

struct diag_request {
	char *buf;
	int length;
	int actual;
	int status;
	void *context;
};

struct usb_diag_ch {
	const char *name;
	struct list_head list;
	void (*notify)(void *priv, unsigned int event,
			struct diag_request *d_req);
	void *priv;
	void *priv_usb;
};

#if IS_ENABLED(CONFIG_USB_F_DIAG)
int usb_diag_request_size(struct usb_diag_ch *ch);
struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
		void (*notify)(void *, unsigned int, struct diag_request *));
void usb_diag_close(struct usb_diag_ch *ch);
int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read);
int usb_diag_read(struct usb_diag_ch *ch, struct diag_request *d_req);
int usb_diag_write(struct usb_diag_ch *ch, struct diag_request *d_req);
#else
static inline struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
		void (*notify)(void *, unsigned int, struct diag_request *))
{
	return ERR_PTR(-ENODEV);
}
static inline void usb_diag_close(struct usb_diag_ch *ch)
{
}
static inline
int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read)
{
	return -ENODEV;
}
static inline
int usb_diag_read(struct usb_diag_ch *ch, struct diag_request *d_req)
{
	return -ENODEV;
}
static inline
int usb_diag_write(struct usb_diag_ch *ch, struct diag_request *d_req)
{
	return -ENODEV;
}
#endif /* CONFIG_USB_F_DIAG */
#endif /* _DRIVERS_USB_DIAG_H_ */