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

Commit 36e574fe authored by Naveen Jain's avatar Naveen Jain Committed by Greg Kroah-Hartman
Browse files

Staging: ti-st: fix protocol counting



Older mechanism of counting the number of protocols
registered with ST was slow, in-efficient.
It used to check the protocol data for NULL for each
registration/unregistration.

With this change, counting protocols in maintained by
a single counter protos_registered.

Counting protocols is not just for debug purposes

Signed-off-by: default avatarNaveen Jain <naveen_jain@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e2a53282
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -584,7 +584,8 @@ void kim_st_list_protocols(struct st_data_s *st_gdata, char *buf)
	}
	sprintf(buf, "%s\n", buf);
#else /* limited info */
	sprintf(buf, "BT=%c\nFM=%c\nGPS=%c\n",
	sprintf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n",
			st_gdata->protos_registered,
			st_gdata->list[ST_BT] != NULL ? 'R' : 'U',
			st_gdata->list[ST_FM] != NULL ? 'R' : 'U',
			st_gdata->list[ST_GPS] != NULL ? 'R' : 'U');
@@ -630,6 +631,7 @@ long st_register(struct st_proto_s *new_proto)
		st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE);

		st_gdata->list[new_proto->type] = new_proto;
		st_gdata->protos_registered++;
		new_proto->write = st_write;

		set_bit(ST_REG_PENDING, &st_gdata->st_state);
@@ -673,7 +675,6 @@ long st_register(struct st_proto_s *new_proto)
		if ((st_gdata->protos_registered != ST_EMPTY) &&
		    (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
			pr_info(" call reg complete callback ");
			st_gdata->protos_registered++;
			st_reg_complete(st_gdata, ST_SUCCESS);
		}
		clear_bit(ST_REG_PENDING, &st_gdata->st_state);
@@ -689,6 +690,7 @@ long st_register(struct st_proto_s *new_proto)

		spin_lock_irqsave(&st_gdata->lock, flags);
		st_gdata->list[new_proto->type] = new_proto;
		st_gdata->protos_registered++;
		new_proto->write = st_write;
		spin_unlock_irqrestore(&st_gdata->lock, flags);
		return err;
@@ -712,6 +714,7 @@ long st_register(struct st_proto_s *new_proto)
			break;
		}
		st_gdata->list[new_proto->type] = new_proto;
		st_gdata->protos_registered++;
		new_proto->write = st_write;

		/* lock already held before entering else */