linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Mikel Astiz <mikel.astiz.oss@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: Re: [RFC v2 01/11] core: Add btd_service to represent device services
Date: Wed, 17 Apr 2013 12:44:57 +0300	[thread overview]
Message-ID: <20130417094457.GA8155@x220> (raw)
In-Reply-To: <1365162348-25541-2-git-send-email-mikel.astiz.oss@gmail.com>

Hi Mikel,

I did a quick read through of the patches and in general they seem quite
good. A couple of issues though:

> +struct btd_service *service_create(struct btd_device *device,
> +						struct btd_profile *profile)
> +{
> +	struct btd_service *service;
> +
> +	service = g_try_new0(struct btd_service, 1);
> +	if (!service) {
> +		error("service_create: failed to alloc memory");
> +		return NULL;
> +	}
> +
> +	service->ref = 1;
> +	service->device = btd_device_ref(device);

I don't think we want to have this pointer impacting reference count of
the device. The device "owns" the service and maintains a list of them
so when device.c calls service_create it shouldn't cause a new
reference for the device. We follow the same principle with adapters and
devices too: when an adapter creates a new device object the device
objects adapter pointer doesn't use ref().

One thing that you may need to pay attention to though is if for
whatever reason (buggy plugins) all service references aren't released
when a device gets removed, the device pointer should at least get set
to NULL (or maybe just have a big assert if this should only happen in
the case of a bug).

> +struct btd_service *service_create(struct btd_device *device,
> +						struct btd_profile *profile);
> +
> +struct btd_service *btd_service_ref(struct btd_service *service);
> +void btd_service_unref(struct btd_service *service);
> +
> +struct btd_device *btd_service_get_device(const struct btd_service *service);
> +struct btd_profile *btd_service_get_profile(const struct btd_service *service);
> +btd_service_state_t btd_service_get_state(const struct btd_service *service);
> +
> +void btd_service_set_user_data(struct btd_service *service, void *user_data);
> +void *btd_service_get_user_data(const struct btd_service *service);
> +int btd_service_get_error(const struct btd_service *service);
> +
> +void btd_service_probed(struct btd_service *service);
> +void btd_service_connecting(struct btd_service *service);
> +void btd_service_connecting_complete(struct btd_service *service, int err);
> +void btd_service_disconnecting(struct btd_service *service);
> +void btd_service_disconnecting_complete(struct btd_service *service, int err);
> +void btd_service_unavailable(struct btd_service *service);

Since you're adding all these APIs without any actual users in this
patch I'd appreciate a short description of the expected uses of them.
You could e.g. put it to the cover letter or even the commit message.

Johan

  reply	other threads:[~2013-04-17  9:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 11:45 [RFC v2 00/11] struct btd_service in core Mikel Astiz
2013-04-05 11:45 ` [RFC v2 01/11] core: Add btd_service to represent device services Mikel Astiz
2013-04-17  9:44   ` Johan Hedberg [this message]
2013-04-05 11:45 ` [RFC v2 02/11] device: Use btd_service to represent profiles Mikel Astiz
2013-04-05 11:45 ` [RFC v2 03/11] device: Replace connected_profiles with btd_service Mikel Astiz
2013-04-05 11:45 ` [RFC v2 04/11] device: Find services instead of profiles Mikel Astiz
2013-04-05 11:45 ` [RFC v2 05/11] device: Replace pending profile list with services Mikel Astiz
2013-04-05 11:45 ` [RFC v2 06/11] profile: Use btd_service for probing profiles Mikel Astiz
2013-04-05 11:45 ` [RFC v2 07/11] audio: Hold a reference to btd_service Mikel Astiz
2013-04-05 11:45 ` [RFC v2 08/11] network: " Mikel Astiz
2013-04-05 11:45 ` [RFC v2 09/11] input: " Mikel Astiz
2013-04-05 11:45 ` [RFC v2 10/11] service: Add callbacks to track state changes Mikel Astiz
2013-04-05 11:45 ` [RFC v2 11/11] profile: Use btd_service for connect/disconnect Mikel Astiz
2013-04-17  8:22 ` [RFC v2 00/11] struct btd_service in core Mikel Astiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130417094457.GA8155@x220 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz.oss@gmail.com \
    --cc=mikel.astiz@bmw-carit.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).