Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp693116pxk; Thu, 24 Sep 2020 16:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/6n4ZgIR5XPwXD0FqGBXtDUu/YgCMBbQtIOUIDTo0VCOodu5fVcmhJJNzhcTOvu5KD44x X-Received: by 2002:a17:906:311a:: with SMTP id 26mr35751ejx.226.1600989935671; Thu, 24 Sep 2020 16:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600989935; cv=none; d=google.com; s=arc-20160816; b=HNSxhz/lhc8Vq0sL8ufgbu1yrPRUwon4zFAJ8I2R/6Ga01AcRI7G58PNwOZ2McAonX 9GBW7fJILEBgF6B9X4iRGIZsLneTIM0fc08zdQyDmzhfYpTqKLJtLgfxYOazV32XoB+Y LqameMZC2RKGV1OGdqauanOujfeM5DgGSOub7MzjfRMLXxBM+rzZww4sjnb6bDN/u8FG KtX4tQVktT5MbT9yhwqwnYTtqv0frbBScLejdSBsXyiFPeTW3kqvtHqPMdCKkq38/E8J /PRcz6hbrrUVzCxgrMElzSQo6x2a3kbMPG6VQI4oCEVQqyHEp6F8pAx04Tvp9sSn4vIz meyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ywS3L0LbtMmnI8SMeK1q/vOdWENG8lGa1ljoO5LFLLY=; b=GfrYSBxfDmGTezYXrEYg5eyGtB83camcrOegzXW0NOc7q2fz3jtFoYx/mdZbxuKnqM SkElGBkScYHRcNEyBuMXbUBMpDb7dArTFESmFB+Uf2AKYa/Htv0fCnxrrFwek1lIgTZ9 mpm9uhNwdYBWipDVyXX/9tOxy9FP2bnLweG+SotJIylGoYdjMz9uBATTMiXc4hkhX7Fs ym4LCjqf/Dk2Ogf23PJIRmayC8ufulczooqkwi18C9Jeng8x201xutxsxiamvBnZbvjY hAw2OUiB6tYtCTHg5JhERNOVFqJRcHlxrfFycWOOOE+Th9y3RN8nEwKpTyLNsPzephXg 6CRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EoTc6W0k; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si591833edv.217.2020.09.24.16.25.10; Thu, 24 Sep 2020 16:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EoTc6W0k; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726557AbgIXXZG (ORCPT + 99 others); Thu, 24 Sep 2020 19:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgIXXZG (ORCPT ); Thu, 24 Sep 2020 19:25:06 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F53DC0613CE for ; Thu, 24 Sep 2020 16:25:06 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id q21so573772ota.8 for ; Thu, 24 Sep 2020 16:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ywS3L0LbtMmnI8SMeK1q/vOdWENG8lGa1ljoO5LFLLY=; b=EoTc6W0kKZXyRBXc7R+K82CeQ0SOJBKcksJxmm6BSMbHDOpBdTm71MwR72XdATHII+ 1CjMwSjoykIy9DTXI3OkvC0NjsSccPU2XwEbmTvZ398VEby2HD2nyxoorr2F4fmi01tT C1TGrUSxDWeFIG/fvqmKiFOxOzih2rwdgmXAbmLsJ6SiIKSDPzkqTG1RcHCbWqCcsi3/ DMBAtdIVwPX32WJ/jjEGDHSz8fIWlJJE372toAhfSLwR8l6L3FzGf5803RckbGpWcolS TtGVvFj4J4bBadRSJheEwldixTVYYG4o3QvEl5WnJvDdhKBbYGbf8+Dl17xaAfYjC8Bl x4BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ywS3L0LbtMmnI8SMeK1q/vOdWENG8lGa1ljoO5LFLLY=; b=gqr3rWq/ttoH7qgyyQkfIUGX9qN6sKV+xWY6npUvVY7DLcsPprbNH36Sz2L2ZgmZZT wtCzbcRb1UsB1VOIuWOQK64ZIzwr6ipfCTYKEMnftSX9944htgg1QGV205zLEfneRpUu uOa/WlIrBEDMK47j589uX2lLmu7t8K3A38JcU6Sm5uD+KYdZ/yCLOftUj8YMml99PHqo aK1fejiPlaUS3Hv8AVnN+n5ywul02g1qL5phlh5IK+gSUq7Z02Vk28LFbqXrc00afATB 8x4HdslzXCUNiCgyEo4fD+hIl3bRmyP5qLnpTf47CGN3d4gT5SpvbTX2BPjDw/tYdpDe +cgQ== X-Gm-Message-State: AOAM5335bKm3xNzN34PcXKACkiy1BkSSyjpJyc/GrXOdCn6bfExb+hlf j6sEjV4fGULDq+B3WMmbt1tJvjU26hXl/EtwIxgqmK+W X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr1012089otc.88.1600989905510; Thu, 24 Sep 2020 16:25:05 -0700 (PDT) MIME-Version: 1.0 References: <20200924182002.22978-1-inga.stotland@intel.com> In-Reply-To: <20200924182002.22978-1-inga.stotland@intel.com> From: Luiz Augusto von Dentz Date: Thu, 24 Sep 2020 16:24:53 -0700 Message-ID: Subject: Re: [PATCH BlueZ] shared/io-ell: Fix ELL io wrapper To: Inga Stotland Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Inga, On Thu, Sep 24, 2020 at 11:20 AM Inga Stotland wrote: > > This modifies the internal io structure inside io-ell to retain > correct user data associated with write and read handlers and > to return these data with the corresponding callbacks. > --- > src/shared/io-ell.c | 54 +++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 50 insertions(+), 4 deletions(-) > > diff --git a/src/shared/io-ell.c b/src/shared/io-ell.c > index c4a115478..485c613e0 100644 > --- a/src/shared/io-ell.c > +++ b/src/shared/io-ell.c > @@ -22,8 +22,48 @@ > > struct io { > struct l_io *l_io; > + io_callback_func_t read_cb; > + io_destroy_func_t read_destroy; > + void *read_data; > + io_callback_func_t write_cb; > + io_destroy_func_t write_destroy; > + void *write_data; > }; > > +static bool read_callback(struct l_io *l_io, void *user_data) > +{ > + struct io *io = user_data; > + bool result = false; > + > + if (!io) > + return false; > + > + if (io->read_cb) > + result = io->read_cb(io, io->read_data); > + > + if (io->read_destroy) > + io->read_destroy(io->read_data); > + > + return result; > +} > + > +static bool write_callback(struct l_io *l_io, void *user_data) > +{ > + struct io *io = user_data; > + bool result = false; > + > + if (!io) > + return false; > + > + if (io->write_cb) > + result = io->write_cb(io, io->write_data); > + > + if (io->write_destroy) > + io->write_destroy(io->write_data); > + > + return result; > +} > + > struct io *io_new(int fd) > { > struct io *io; > @@ -80,8 +120,11 @@ bool io_set_read_handler(struct io *io, io_callback_func_t callback, > if (!io || !io->l_io) > return false; > > - return l_io_set_read_handler(io->l_io, (l_io_read_cb_t) callback, > - user_data, destroy); > + io->read_cb = callback; > + io->read_data = user_data; > + io->read_destroy = destroy; > + > + return l_io_set_read_handler(io->l_io, read_callback, io, NULL); > } > > bool io_set_write_handler(struct io *io, io_callback_func_t callback, > @@ -90,8 +133,11 @@ bool io_set_write_handler(struct io *io, io_callback_func_t callback, > if (!io || !io->l_io) > return false; > > - return l_io_set_write_handler(io->l_io, (l_io_write_cb_t) callback, > - user_data, destroy); > + io->write_cb = callback; > + io->write_data = user_data; > + io->write_destroy = destroy; > + > + return l_io_set_write_handler(io->l_io, write_callback, io, NULL); > } > > bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback, > -- > 2.26.2 > Applied, thanks. -- Luiz Augusto von Dentz