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

Commit fffe6d0f authored by Manu Gautam's avatar Manu Gautam
Browse files

USB: gadget: rndis: Allow reading of 'rx_trigger' attribute value



rx_trigger attribute is used by userspace to kickstart RX
once end to end data path is setup on USB connection.
Currently this attribute is write only. Make it readable
so that userspace can read it back during fast USB connect
disconnect scenarios which results in net core missing to
send NETLINK DISCONNECT events. Userspace can read this back
on CONNECT to figure out any missed disconnect events.

Change-Id: Ief1d93b1e29103336b672cf0e8abcfe881aaa617
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent 163e94f6
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -2260,19 +2260,30 @@ static ssize_t rndis_transports_store(struct device *dev,
static DEVICE_ATTR(rndis_transports, S_IRUGO | S_IWUSR, rndis_transports_show,
					       rndis_transports_store);

static ssize_t rndis_rx_trigger_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	bool write = false;
	int rx_trigger = rndis_rx_trigger(write);

	return snprintf(buf, PAGE_SIZE, "%d\n", rx_trigger);
}

static ssize_t rndis_rx_trigger_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	int value;
	bool write = true;

	if (sscanf(buf, "%d", &value) == 1) {
		rndis_rx_trigger();
		rndis_rx_trigger(write);
		return size;
	}
	return -EINVAL;
}

static DEVICE_ATTR(rx_trigger, S_IWUSR, NULL,
static DEVICE_ATTR(rx_trigger, S_IRUGO | S_IWUSR,
					 rndis_rx_trigger_show,
					 rndis_rx_trigger_store);

static ssize_t rndis_pkt_alignment_factor_show(struct device *dev,
+3 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ struct f_rndis {
static struct f_rndis *__rndis;

int
rndis_rx_trigger(void)
rndis_rx_trigger(bool write)
{
	struct f_rndis *rndis = __rndis;

@@ -104,6 +104,8 @@ rndis_rx_trigger(void)
		pr_err("can't set rx trigger\n");
		return -EINVAL;
	}
	if (!write)
		return rndis->port.rx_triggered;

	if (rndis->port.rx_triggered)
		return 0;
+2 −2
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ int eem_bind_config(struct usb_configuration *c, struct eth_dev *dev);

int rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
		u32 vendorID, const char *manufacturer, struct eth_dev *dev);
int rndis_rx_trigger(void);
int rndis_rx_trigger(bool);

#else

@@ -149,7 +149,7 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
}

static inline int
rndis_rx_trigger(void)
rndis_rx_trigger(bool)
{
	return 0;
}