diff options
author | Dorota Moskal <dorota.moskal@tieto.com> | 2012-10-08 21:52:11 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-10-08 21:52:11 +0200 |
commit | 2e7daf717d1c0fea50f1304b2f79d62ff531fc5a (patch) | |
tree | fe18dfc312f8c2f584fe8a7da4063ef5f4d3a4b9 /src/tag.c | |
parent | 00ef35c8c70c681accfe30dbba15a6de5d3e5401 (diff) | |
download | neard-2e7daf717d1c0fea50f1304b2f79d62ff531fc5a.tar.gz neard-2e7daf717d1c0fea50f1304b2f79d62ff531fc5a.tar.bz2 neard-2e7daf717d1c0fea50f1304b2f79d62ff531fc5a.zip |
tag: Don't check presence while busy
When reading, writing or formating is in progress, no check presence
should be done.
Diffstat (limited to 'src/tag.c')
-rw-r--r-- | src/tag.c | 41 |
1 files changed, 33 insertions, 8 deletions
@@ -230,6 +230,8 @@ static DBusMessage *set_property(DBusConnection *conn, static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status) { + __near_adapter_start_check_presence(adapter_idx, target_idx); + __near_adapter_tags_changed(adapter_idx); } @@ -245,7 +247,7 @@ static void write_cb(uint32_t adapter_idx, uint32_t target_idx, int status) tag = near_tag_get_tag(adapter_idx, target_idx); if (conn == NULL || tag == NULL) - return; + goto out; if (status != 0) { reply = __near_error_failed(tag->write_msg, EINVAL); @@ -263,8 +265,17 @@ static void write_cb(uint32_t adapter_idx, uint32_t target_idx, int status) tag->records = NULL; g_free(tag->data); - if (status == 0) + if (status == 0) { + /* + * If writing succeeded, + * check presence will be restored after reading + */ __near_tag_read(tag, tag_read_cb); + return; + } + +out: + __near_adapter_start_check_presence(tag->adapter_idx, tag->target_idx); } static void format_cb(uint32_t adapter_idx, uint32_t target_idx, int status) @@ -908,6 +919,9 @@ int __near_tag_read(struct near_tag *tag, near_tag_io_cb cb) DBG("type 0x%x", tag->type); + /* Stop check presence while reading */ + __near_adapter_stop_check_presence(tag->adapter_idx, tag->target_idx); + for (list = driver_list; list; list = list->next) { struct near_tag_driver *driver = list->data; @@ -936,21 +950,32 @@ int __near_tag_write(struct near_tag *tag, DBG("driver type 0x%x", driver->type); if (driver->type == tag->type) { + /* Stop check presence while writing */ + __near_adapter_stop_check_presence(tag->adapter_idx, + tag->target_idx); + if (tag->blank == TRUE && driver->format != NULL) { DBG("Blank tag detected, formatting"); err = driver->format(tag->adapter_idx, tag->target_idx, format_cb); - if (err < 0) - return err; } else { - return driver->write(tag->adapter_idx, - tag->target_idx, ndef, - cb); + err = driver->write(tag->adapter_idx, + tag->target_idx, ndef, + cb); } + + break; } } - return 0; + if (list == NULL) + err = -EOPNOTSUPP; + + if (err < 0) + __near_adapter_start_check_presence(tag->adapter_idx, + tag->target_idx); + + return err; } int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb) |