lkml.org 
[lkml]   [2022]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 1/6] device property: Helper to match multiple connections
    On Fri, Feb 18, 2022 at 11:00:45AM -0800, Bjorn Andersson wrote:
    > On Wed 09 Feb 04:30 PST 2022, Andy Shevchenko wrote:
    > > On Mon, Feb 07, 2022 at 07:19:39PM -0800, Bjorn Andersson wrote:

    ...

    > > > +int fwnode_connection_find_matches(struct fwnode_handle *fwnode,
    > > > + const char *con_id, void *data,
    > > > + devcon_match_fn_t match,
    > > > + void **matches, unsigned int matches_len)
    > > > +{
    > > > + unsigned int count;
    > > > +
    > > > + if (!fwnode || !match || !matches)
    > >
    > > !matches case may be still useful to get the count and allocate memory by
    > > caller. Please, consider this case.
    > >
    >
    > As discussed in previous version, and described in the commit message,
    > the returned value of "match" is a opaque pointer to something which
    > has to be passed back to the caller in order to be cleaned up.
    >
    > E.g. the typec mux code returns a pointer to a typec_mux/switch object
    > with a refcounted struct device within, or an ERR_PTR().
    >
    > So unfortunately we can must gather the results into matches and pass it
    > back to the caller to take consume or clean up.


    It's fine. You have **matches, means pointer of an opaque pointer.
    What I'm talking about is memory allocation for and array of _pointers_.
    That's what caller very much aware of and can allocate on heap. So, please
    consider this case.

    --
    With Best Regards,
    Andy Shevchenko


    \
     
     \ /
      Last update: 2022-02-20 12:21    [W:3.826 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site