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

Commit 02ea1307 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: serial: Add SoftAP + DUN flags to serial device interface"

parents 7ce9090a 7e93176c
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -1539,6 +1539,53 @@ static ssize_t serial_xport_names_show(struct device *dev,
{
	return snprintf(buf, PAGE_SIZE, "%s\n", serial_xport_names);
}
static ssize_t serial_modem_is_connected_show(
		struct device *device, struct device_attribute *attr,
		char *buff)
{
	unsigned int is_connected = gserial_is_connected();

	return snprintf(buff, PAGE_SIZE, "%u\n", is_connected);
}

static ssize_t dun_w_softap_enable_show(
		struct device *device, struct device_attribute *attr,
		char *buff)
{
	unsigned int dun_w_softap_enable = gserial_is_dun_w_softap_enabled();

	return snprintf(buff, PAGE_SIZE, "%u\n", dun_w_softap_enable);
}

static ssize_t dun_w_softap_enable_store(
		struct device *device, struct device_attribute *attr,
		const char *buff, size_t size)
{
	unsigned int dun_w_softap_enable;

	sscanf(buff, "%u", &dun_w_softap_enable);

	gserial_dun_w_softap_enable(dun_w_softap_enable);

	return size;
}

static ssize_t dun_w_softap_active_show(
		struct device *device, struct device_attribute *attr,
		char *buff)
{
	unsigned int dun_w_softap_active = gserial_is_dun_w_softap_active();

	return snprintf(buff, PAGE_SIZE, "%u\n", dun_w_softap_active);
}

static DEVICE_ATTR(is_connected_flag, S_IRUGO, serial_modem_is_connected_show,
		NULL);
static DEVICE_ATTR(dun_w_softap_enable, S_IRUGO | S_IWUSR,
	dun_w_softap_enable_show, dun_w_softap_enable_store);
static DEVICE_ATTR(dun_w_softap_active, S_IRUGO, dun_w_softap_active_show,
		NULL);


static DEVICE_ATTR(transports, S_IWUSR, NULL, serial_transports_store);
static struct device_attribute dev_attr_serial_xport_names =
@@ -1549,6 +1596,9 @@ static struct device_attribute dev_attr_serial_xport_names =
static struct device_attribute *serial_function_attributes[] = {
					&dev_attr_transports,
					&dev_attr_serial_xport_names,
					&dev_attr_is_connected_flag,
					&dev_attr_dun_w_softap_enable,
					&dev_attr_dun_w_softap_active,
					NULL };

static int serial_function_init(struct android_usb_function *f,
+32 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ static struct port_info {
	unsigned		port_num;
	unsigned char		client_port_num;
	struct f_gser		*gser_ptr;
	bool			dun_w_softap_enable;
} gserial_ports[GSERIAL_NO_PORTS];

static int gser_open_dev(struct inode *ip, struct file *fp);
@@ -1172,6 +1173,37 @@ int gserial_init_port(int port_num, const char *name,
	return ret;
}


bool gserial_is_connected(void)
{
	if (gserial_ports[0].gser_ptr != NULL)
		return gserial_ports[0].gser_ptr->online;
	return 0;
}

bool gserial_is_dun_w_softap_enabled(void)
{
	if (gserial_ports[0].gser_ptr != NULL)
		return gserial_ports[0].dun_w_softap_enable;
	return 0;
}

void gserial_dun_w_softap_enable(bool enable)
{
	pr_debug("android_usb: Setting dun_w_softap_enable to %u.",
		enable);

	gserial_ports[0].dun_w_softap_enable = enable;
}

bool gserial_is_dun_w_softap_active(void)
{
	if (gserial_ports[0].gser_ptr != NULL)
		return gserial_ports[0].dun_w_softap_enable &&
			gserial_ports[0].gser_ptr->online;
	return 0;
}

static inline int gser_device_lock(atomic_t *excl)
{
	if (atomic_inc_return(excl) == 1) {
+5 −0
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ extern int gport_setup(struct usb_configuration *c);
extern void gport_cleanup(void);
extern int gserial_init_port(int port_num, const char *name,
					const char *port_name);
extern bool gserial_is_connected(void);
extern bool gserial_is_dun_w_softap_enabled(void);
extern void gserial_dun_w_softap_enable(bool enable);
extern bool gserial_is_dun_w_softap_active(void);


int acm_port_setup(struct usb_configuration *c);
void acm_port_cleanup(void);