Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: backend: introduce struct iio_backend_info

Instead of only passing the backend ops when calling
devm_iio_backend_register(), pass an info like structure that will
contains the ops and additional information. Fow now, the backend name
is being added as that will be used by the debugFS interface introduced
in a later patch.

It also opens the door for further customizations passed by backends.

All users of devm_iio_backend_register() were updated accordingly.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-1-4cb62852f0d0@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
2256f37e 958000df

+28 -8
+6 -1
drivers/iio/adc/adi-axi-adc.c
··· 273 273 .reg_stride = 4, 274 274 }; 275 275 276 - static const struct iio_backend_ops adi_axi_adc_generic = { 276 + static const struct iio_backend_ops adi_axi_adc_ops = { 277 277 .enable = axi_adc_enable, 278 278 .disable = axi_adc_disable, 279 279 .data_format_set = axi_adc_data_format_set, ··· 285 285 .iodelay_set = axi_adc_iodelays_set, 286 286 .test_pattern_set = axi_adc_test_pattern_set, 287 287 .chan_status = axi_adc_chan_status, 288 + }; 289 + 290 + static const struct iio_backend_info adi_axi_adc_generic = { 291 + .name = "axi-adc", 292 + .ops = &adi_axi_adc_ops, 288 293 }; 289 294 290 295 static int adi_axi_adc_probe(struct platform_device *pdev)
+6 -1
drivers/iio/dac/adi-axi-dac.c
··· 507 507 return 0; 508 508 } 509 509 510 - static const struct iio_backend_ops axi_dac_generic = { 510 + static const struct iio_backend_ops axi_dac_generic_ops = { 511 511 .enable = axi_dac_enable, 512 512 .disable = axi_dac_disable, 513 513 .request_buffer = axi_dac_request_buffer, ··· 517 517 .ext_info_get = axi_dac_ext_info_get, 518 518 .data_source_set = axi_dac_data_source_set, 519 519 .set_sample_rate = axi_dac_set_sample_rate, 520 + }; 521 + 522 + static const struct iio_backend_info axi_dac_generic = { 523 + .name = "axi-dac", 524 + .ops = &axi_dac_generic_ops, 520 525 }; 521 526 522 527 static const struct regmap_config axi_dac_regmap_config = {
+5 -5
drivers/iio/industrialio-backend.c
··· 641 641 /** 642 642 * devm_iio_backend_register - Device managed backend device register 643 643 * @dev: Backend device being registered 644 - * @ops: Backend ops 644 + * @info: Backend info 645 645 * @priv: Device private data 646 646 * 647 - * @ops is mandatory. Not providing it results in -EINVAL. 647 + * @info is mandatory. Not providing it results in -EINVAL. 648 648 * 649 649 * RETURNS: 650 650 * 0 on success, negative error number on failure. 651 651 */ 652 652 int devm_iio_backend_register(struct device *dev, 653 - const struct iio_backend_ops *ops, void *priv) 653 + const struct iio_backend_info *info, void *priv) 654 654 { 655 655 struct iio_backend *back; 656 656 657 - if (!ops) 657 + if (!info || !info->ops) 658 658 return dev_err_probe(dev, -EINVAL, "No backend ops given\n"); 659 659 660 660 /* ··· 667 667 if (!back) 668 668 return -ENOMEM; 669 669 670 - back->ops = ops; 670 + back->ops = info->ops; 671 671 back->owner = dev->driver->owner; 672 672 back->dev = dev; 673 673 back->priv = priv;
+11 -1
include/linux/iio/backend.h
··· 115 115 const struct iio_chan_spec *chan, char *buf); 116 116 }; 117 117 118 + /** 119 + * struct iio_backend_info - info structure for an iio_backend 120 + * @name: Backend name. 121 + * @ops: Backend operations. 122 + */ 123 + struct iio_backend_info { 124 + const char *name; 125 + const struct iio_backend_ops *ops; 126 + }; 127 + 118 128 int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan); 119 129 int iio_backend_chan_disable(struct iio_backend *back, unsigned int chan); 120 130 int devm_iio_backend_enable(struct device *dev, struct iio_backend *back); ··· 161 151 struct fwnode_handle *fwnode); 162 152 163 153 int devm_iio_backend_register(struct device *dev, 164 - const struct iio_backend_ops *ops, void *priv); 154 + const struct iio_backend_info *info, void *priv); 165 155 166 156 #endif