Message ID | 20240618160836.945242-4-olivier.moysan@foss.st.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: adc: dfsdm: add scaling support | expand |
On Tue, 2024-06-18 at 18:08 +0200, Olivier Moysan wrote: > Add an API to support IIO generic channels binding: > http://devicetree.org/schemas/iio/adc/adc.yaml# > This new API is needed, as generic channel DT node > isn't populated as a device. > Add devm_iio_backend_subnode_get() to allow an IIO device > backend consumer to configure backend phandles in its > child nodes. > > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> > --- Again small notes nits. With it: Reviewed-by: Nuno Sa <nuno.sa@analog.com> > drivers/iio/industrialio-backend.c | 48 ++++++++++++++++++++++-------- > include/linux/iio/backend.h | 2 ++ > 2 files changed, 38 insertions(+), 12 deletions(-) > > diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio- > backend.c > index d3db048c086b..e9d29131634d 100644 > --- a/drivers/iio/industrialio-backend.c > +++ b/drivers/iio/industrialio-backend.c > @@ -575,17 +575,8 @@ static int __devm_iio_backend_get(struct device *dev, struct > iio_backend *back) > return 0; > } > > -/** > - * devm_iio_backend_get - Device managed backend device get > - * @dev: Consumer device for the backend > - * @name: Backend name > - * > - * Get's the backend associated with @dev. > - * > - * RETURNS: > - * A backend pointer, negative error pointer otherwise. > - */ > -struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) > +static struct iio_backend *__devm_iio_backend_node_get(struct device *dev, const > char *name, > + struct fwnode_handle *node) I would call it __devm_iio_backend_fwnode_get(). Also the parameter node -> fwnode. > { > struct fwnode_handle *fwnode; > struct iio_backend *back; > @@ -602,7 +593,7 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, > const char *name) > index = 0; > } > > - fwnode = fwnode_find_reference(dev_fwnode(dev), "io-backends", index); > + fwnode = fwnode_find_reference(node, "io-backends", index); > if (IS_ERR(fwnode)) { > dev_err_probe(dev, PTR_ERR(fwnode), > "Cannot get Firmware reference\n"); > @@ -625,8 +616,41 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, > const char *name) > fwnode_handle_put(fwnode); > return ERR_PTR(-EPROBE_DEFER); > } > + > +/** > + * devm_iio_backend_get - Device managed backend device get > + * @dev: Consumer device for the backend > + * @name: Backend name > + * > + * Get's the backend associated with @dev. > + * > + * RETURNS: > + * A backend pointer, negative error pointer otherwise. > + */ > +struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) > +{ > + return __devm_iio_backend_node_get(dev, name, dev_fwnode(dev)); > +} > EXPORT_SYMBOL_NS_GPL(devm_iio_backend_get, IIO_BACKEND); > > +/** > + * devm_iio_backend_subnode_get - Device managed backend device get > + * @dev: Consumer device for the backend > + * @name: Backend name > + * @node: Firmware node of the backend consumer > + * > + * Get's the backend associated with @dev. > + * > + * RETURNS: > + * A backend pointer, negative error pointer otherwise. > + */ > +struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char > *name, > + struct fwnode_handle *node) Again, for consistency devm_iio_backend_fwnode_get(). And node -> fwnode - Nuno Sá
On 6/19/24 07:31, Nuno Sá wrote: > On Tue, 2024-06-18 at 18:08 +0200, Olivier Moysan wrote: >> Add an API to support IIO generic channels binding: >> http://devicetree.org/schemas/iio/adc/adc.yaml# >> This new API is needed, as generic channel DT node >> isn't populated as a device. >> Add devm_iio_backend_subnode_get() to allow an IIO device >> backend consumer to configure backend phandles in its >> child nodes. >> >> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> >> --- > > Again small notes nits. With it: > > Reviewed-by: Nuno Sa <nuno.sa@analog.com> > >> drivers/iio/industrialio-backend.c | 48 ++++++++++++++++++++++-------- >> include/linux/iio/backend.h | 2 ++ >> 2 files changed, 38 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio- >> backend.c >> index d3db048c086b..e9d29131634d 100644 >> --- a/drivers/iio/industrialio-backend.c >> +++ b/drivers/iio/industrialio-backend.c >> @@ -575,17 +575,8 @@ static int __devm_iio_backend_get(struct device *dev, struct >> iio_backend *back) >> return 0; >> } >> >> -/** >> - * devm_iio_backend_get - Device managed backend device get >> - * @dev: Consumer device for the backend >> - * @name: Backend name >> - * >> - * Get's the backend associated with @dev. >> - * >> - * RETURNS: >> - * A backend pointer, negative error pointer otherwise. >> - */ >> -struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) >> +static struct iio_backend *__devm_iio_backend_node_get(struct device *dev, const >> char *name, >> + struct fwnode_handle *node) > > I would call it __devm_iio_backend_fwnode_get(). Also the parameter node -> fwnode. > >> { >> struct fwnode_handle *fwnode; >> struct iio_backend *back; >> @@ -602,7 +593,7 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, >> const char *name) >> index = 0; >> } >> >> - fwnode = fwnode_find_reference(dev_fwnode(dev), "io-backends", index); >> + fwnode = fwnode_find_reference(node, "io-backends", index); >> if (IS_ERR(fwnode)) { >> dev_err_probe(dev, PTR_ERR(fwnode), >> "Cannot get Firmware reference\n"); >> @@ -625,8 +616,41 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, >> const char *name) >> fwnode_handle_put(fwnode); >> return ERR_PTR(-EPROBE_DEFER); >> } >> + >> +/** >> + * devm_iio_backend_get - Device managed backend device get >> + * @dev: Consumer device for the backend >> + * @name: Backend name >> + * >> + * Get's the backend associated with @dev. >> + * >> + * RETURNS: >> + * A backend pointer, negative error pointer otherwise. >> + */ >> +struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) >> +{ >> + return __devm_iio_backend_node_get(dev, name, dev_fwnode(dev)); >> +} >> EXPORT_SYMBOL_NS_GPL(devm_iio_backend_get, IIO_BACKEND); >> >> +/** >> + * devm_iio_backend_subnode_get - Device managed backend device get >> + * @dev: Consumer device for the backend >> + * @name: Backend name >> + * @node: Firmware node of the backend consumer >> + * >> + * Get's the backend associated with @dev. >> + * >> + * RETURNS: >> + * A backend pointer, negative error pointer otherwise. >> + */ >> +struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char >> *name, >> + struct fwnode_handle *node) > > Again, for consistency devm_iio_backend_fwnode_get(). And node -> fwnode > Done. Thanks Olivier > - Nuno Sá > >
On Tue, 18 Jun 2024 18:08:29 +0200 Olivier Moysan <olivier.moysan@foss.st.com> wrote: > Add an API to support IIO generic channels binding: > http://devicetree.org/schemas/iio/adc/adc.yaml# > This new API is needed, as generic channel DT node > isn't populated as a device. > Add devm_iio_backend_subnode_get() to allow an IIO device > backend consumer to configure backend phandles in its > child nodes. Really trivial stuff: Don't wrap so far below 75 chars that is typical limit for commit messages. > > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> > + > +/** > + * devm_iio_backend_get - Device managed backend device get > + * @dev: Consumer device for the backend > + * @name: Backend name > + * > + * Get's the backend associated with @dev. > + * > + * RETURNS: > + * A backend pointer, negative error pointer otherwise. > + */ > +struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) > +{ > + return __devm_iio_backend_node_get(dev, name, dev_fwnode(dev)); > +} > EXPORT_SYMBOL_NS_GPL(devm_iio_backend_get, IIO_BACKEND); > > +/** > + * devm_iio_backend_subnode_get - Device managed backend device get Same short description as the one above. Fairly sure this wants to be different! > + * @dev: Consumer device for the backend > + * @name: Backend name > + * @node: Firmware node of the backend consumer > + * > + * Get's the backend associated with @dev. > + * > + * RETURNS: > + * A backend pointer, negative error pointer otherwise. > + */ > +struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char *name, > + struct fwnode_handle *node) > +{ > + return __devm_iio_backend_node_get(dev, name, node); > +} > +EXPORT_SYMBOL_NS_GPL(devm_iio_backend_subnode_get, IIO_BACKEND);
diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c index d3db048c086b..e9d29131634d 100644 --- a/drivers/iio/industrialio-backend.c +++ b/drivers/iio/industrialio-backend.c @@ -575,17 +575,8 @@ static int __devm_iio_backend_get(struct device *dev, struct iio_backend *back) return 0; } -/** - * devm_iio_backend_get - Device managed backend device get - * @dev: Consumer device for the backend - * @name: Backend name - * - * Get's the backend associated with @dev. - * - * RETURNS: - * A backend pointer, negative error pointer otherwise. - */ -struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) +static struct iio_backend *__devm_iio_backend_node_get(struct device *dev, const char *name, + struct fwnode_handle *node) { struct fwnode_handle *fwnode; struct iio_backend *back; @@ -602,7 +593,7 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) index = 0; } - fwnode = fwnode_find_reference(dev_fwnode(dev), "io-backends", index); + fwnode = fwnode_find_reference(node, "io-backends", index); if (IS_ERR(fwnode)) { dev_err_probe(dev, PTR_ERR(fwnode), "Cannot get Firmware reference\n"); @@ -625,8 +616,41 @@ struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) fwnode_handle_put(fwnode); return ERR_PTR(-EPROBE_DEFER); } + +/** + * devm_iio_backend_get - Device managed backend device get + * @dev: Consumer device for the backend + * @name: Backend name + * + * Get's the backend associated with @dev. + * + * RETURNS: + * A backend pointer, negative error pointer otherwise. + */ +struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name) +{ + return __devm_iio_backend_node_get(dev, name, dev_fwnode(dev)); +} EXPORT_SYMBOL_NS_GPL(devm_iio_backend_get, IIO_BACKEND); +/** + * devm_iio_backend_subnode_get - Device managed backend device get + * @dev: Consumer device for the backend + * @name: Backend name + * @node: Firmware node of the backend consumer + * + * Get's the backend associated with @dev. + * + * RETURNS: + * A backend pointer, negative error pointer otherwise. + */ +struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char *name, + struct fwnode_handle *node) +{ + return __devm_iio_backend_node_get(dev, name, node); +} +EXPORT_SYMBOL_NS_GPL(devm_iio_backend_subnode_get, IIO_BACKEND); + /** * __devm_iio_backend_get_from_fwnode_lookup - Device managed fwnode backend device get * @dev: Consumer device for the backend diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h index 81277e5b6160..1050ab68e4e4 100644 --- a/include/linux/iio/backend.h +++ b/include/linux/iio/backend.h @@ -152,6 +152,8 @@ int iio_backend_extend_chan_spec(struct iio_dev *indio_dev, struct iio_chan_spec *chan); void *iio_backend_get_priv(const struct iio_backend *conv); struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name); +struct iio_backend *devm_iio_backend_subnode_get(struct device *dev, const char *name, + struct fwnode_handle *node); struct iio_backend * __devm_iio_backend_get_from_fwnode_lookup(struct device *dev, struct fwnode_handle *fwnode);
Add an API to support IIO generic channels binding: http://devicetree.org/schemas/iio/adc/adc.yaml# This new API is needed, as generic channel DT node isn't populated as a device. Add devm_iio_backend_subnode_get() to allow an IIO device backend consumer to configure backend phandles in its child nodes. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> --- drivers/iio/industrialio-backend.c | 48 ++++++++++++++++++++++-------- include/linux/iio/backend.h | 2 ++ 2 files changed, 38 insertions(+), 12 deletions(-)