Exemplo n.º 1
0
static struct descriptor *descriptor_create(struct gatt_db_attribute *attr,
						struct characteristic *chrc)
{
	struct descriptor *desc;

	desc = new0(struct descriptor, 1);
	desc->chrc = chrc;
	desc->attr = attr;
	desc->handle = gatt_db_attribute_get_handle(attr);

	bt_uuid_to_uuid128(gatt_db_attribute_get_type(attr), &desc->uuid);

	desc->path = g_strdup_printf("%s/desc%04x", chrc->path, desc->handle);

	if (!g_dbus_register_interface(btd_get_dbus_connection(), desc->path,
						GATT_DESCRIPTOR_IFACE,
						descriptor_methods, NULL,
						descriptor_properties,
						desc, descriptor_free)) {
		error("Unable to register GATT descriptor with handle 0x%04x",
								desc->handle);
		descriptor_free(desc);

		return NULL;
	}

	DBG("Exported GATT characteristic descriptor: %s", desc->path);

	if (uuid_cmp(&desc->uuid, GATT_CHARAC_EXT_PROPER_UUID))
		chrc->ext_props_handle = desc->handle;

	return desc;
}
Exemplo n.º 2
0
/**
 * This function must be called by the user driver to unregister itself from
 * the base DMA driver. After doing required checks to verify the handle
 * and engine state, the DMA engine is reset, interrupts are disabled if
 * required, and the BD ring is freed, while returning all the packet buffers
 * to the user driver.
 *
 * @param handle is the handle which was assigned during the registration
 * process.
 *
 * @return XST_FAILURE incase of any error
 * @return 0 incase of success
 *
 * @note This function should not be called in an interrupt context
 *
 *****************************************************************************/
int DmaUnregister(void * handle)
{
    Dma_Engine * eptr;

    printk(KERN_INFO "User unregister for handle %p\n", handle);
    if(DriverState != INITIALIZED)
    {
        printk(KERN_ERR "DMA driver state %d - not ready\n", DriverState);
        return XST_FAILURE;
    }

    eptr = (Dma_Engine *)handle;

    /* Check if this engine's pointer is valid */
    if(eptr == NULL)
    {
        printk(KERN_ERR "Handle is a NULL value\n");
        return XST_FAILURE;
    }

    /* Is the engine assigned to any user? */
    if(eptr->EngineState != USER_ASSIGNED) {
        printk(KERN_ERR "Engine is not assigned to any user\n");
        return XST_FAILURE;
    }

    spin_lock_bh(&DmaLock);

    /* Change DMA engine state */
    eptr->EngineState = UNREGISTERING;

    /* First, reset DMA engine, so that buffers can be removed. */
    printk(KERN_INFO "Resetting DMA engine\n");
    Dma_Reset(eptr);

    /* Next, return all the buffers in the BD ring to the user.
     * And free the BD ring.
     */

    printk("Now checking all descriptors\n");
    spin_unlock_bh(&DmaLock);
    descriptor_free(eptr->pdev, eptr);
    spin_lock_bh(&DmaLock);

    /* Change DMA engine state */
    eptr->EngineState = INITIALIZED;
    dmaData->userCount --;

    printk("DMA driver user count is %d\n", dmaData->userCount);

    spin_unlock_bh(&DmaLock);

    return 0;
}
Exemplo n.º 3
0
static void es_info_free(elementary_stream_info_t* es)
{
    if (es == NULL) {
        return;
    }

    for (size_t i = 0; i < es->descriptors_len; ++i) {
        descriptor_free(es->descriptors[i]);
    }
    g_free(es->descriptors);
    g_slice_free(elementary_stream_info_t, es);
}
Exemplo n.º 4
0
void conditional_access_section_unref(conditional_access_section_t* cas)
{
    if (cas == NULL) {
        return;
    }
    g_return_if_fail(cas->ref_count > 0);
    --cas->ref_count;
    if (cas->ref_count > 0) {
        return;
    }

    for (size_t i = 0; i < cas->descriptors_len; ++i) {
        descriptor_free(cas->descriptors[i]);
    }
    free(cas->descriptors);
    g_slice_free(conditional_access_section_t, cas);
}
Exemplo n.º 5
0
void program_map_section_unref(program_map_section_t* pms)
{
    if (pms == NULL) {
        return;
    }
    g_return_if_fail(pms->ref_count > 0);
    --pms->ref_count;
    if (pms->ref_count > 0) {
        return;
    }

    for (size_t i = 0; i < pms->descriptors_len; ++i) {
        descriptor_free(pms->descriptors[i]);
    }
    free(pms->descriptors);
    for (size_t i = 0; i < pms->es_info_len; ++i) {
        es_info_free(pms->es_info[i]);
    }
    free(pms->es_info);

    g_slice_free(program_map_section_t, pms);
}