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