Re: [RFC v0 01/11] core: Add btd_service to represent device services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mikel,

On Tue, Mar 19, 2013, Mikel Astiz wrote:
> +static char *str_state[] = {
> +	"SERVICE_STATE_UNAVAILABLE",
> +	"SERVICE_STATE_DISCONNECTED",
> +	"SERVICE_STATE_CONNECTING",
> +	"SERVICE_STATE_CONNECTED",
> +	"SERVICE_STATE_DISCONNECTING",
> +};

I'd rather have a separate state2str function with a switch statement
than this array that relies on matching the order of states in the state
enum. Also, you seem to have forgotten the const specifier that should
be used for strings like this (I'm pointing it out since it also applies
to the return type of the state2str function).

> +struct btd_device *service_get_device(struct btd_service *service)
> +{
> +	return service->device;
> +}
> +
> +struct btd_profile *service_get_profile(struct btd_service *service)
> +{
> +	return service->profile;
> +}
> +
> +void service_set_user_data(struct btd_service *service, void *user_data)
> +{
> +	assert(service->state == SERVICE_STATE_UNAVAILABLE);
> +	service->user_data = user_data;
> +}
> +
> +void *service_get_user_data(struct btd_service *service)
> +{
> +	return service->user_data;
> +}
> +
> +int service_get_error(struct btd_service *service)
> +{
> +	return service->err;
> +}
> +
> +service_state_t service_get_state(struct btd_service *service)
> +{
> +	return service->state;
> +}

Why are these functions not prefixed with btd_?

> +void service_probed(struct btd_service *service)
> +{
> +	assert(service->state == SERVICE_STATE_UNAVAILABLE);
> +	service_set_state(service, SERVICE_STATE_DISCONNECTED);
> +}
> +
> +void service_connecting(struct btd_service *service)
> +{
> +	assert(service->state == SERVICE_STATE_DISCONNECTED);
> +	service->err = 0;
> +	service_set_state(service, SERVICE_STATE_CONNECTING);
> +}
> +
> +void service_connecting_complete(struct btd_service *service, int err)
> +{
> +	if (service->state != SERVICE_STATE_DISCONNECTED &&
> +				service->state != SERVICE_STATE_CONNECTING)
> +		return;
> +
> +	service->err = err;
> +
> +	if (err == 0)
> +		service_set_state(service, SERVICE_STATE_CONNECTED);
> +	else
> +		service_set_state(service, SERVICE_STATE_DISCONNECTED);
> +}
> +
> +void service_disconnecting(struct btd_service *service)
> +{
> +	assert(service->state == SERVICE_STATE_CONNECTING ||
> +				service->state == SERVICE_STATE_CONNECTED);
> +	service->err = 0;
> +	service_set_state(service, SERVICE_STATE_DISCONNECTING);
> +}
> +
> +void service_disconnecting_complete(struct btd_service *service, int err)
> +{
> +	if (service->state != SERVICE_STATE_CONNECTED &&
> +				service->state != SERVICE_STATE_DISCONNECTING)
> +		return;
> +
> +	service->err = err;
> +	service_set_state(service, SERVICE_STATE_DISCONNECTED);
> +}
> +
> +void service_unavailable(struct btd_service *service)
> +{
> +	service->profile = NULL;
> +	service->err = 0;
> +	service_set_state(service, SERVICE_STATE_UNAVAILABLE);
> +}

Why aren't these function names prefixed with btd_?

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux