mirror of
https://github.com/torvalds/linux.git
synced 2025-01-01 15:51:46 +00:00
regmap: Add a bulk field API
Useful for devices with many fields. -----BEGIN PGP SIGNATURE----- iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl9yPoATHGJyb29uaWVA a2VybmVsLm9yZwAKCRAk1otyXVSH0JsoB/9zhtYrqKbof0AKuMfEeO+pPo4dC/9l O7ENgSXCb9PWy0auVpU62ISXBPadbbrQXXe3hJ1Zof5q17lYqbaLM7Uem3bxIYtc 0HHRIb49R1sP+99T2JB3RDu/ykzHJsfxCkLgMR5MvBgS5e3KKf0SqZgNSVTYT4Y5 oPt81sxW56Z8FLrLn0j1sVDXlro4/uBpDOcHyzgq4GWgQ6ACvnIOH+PQUTTcGBfT LtIkRMO8mHNKsDCy9Qy12NRsaparIbYb7KKEY9IR+6TN+qJ/g5PJQcPmsU6b0NIl pb7fv4IRTvPDaEPa1g20U88qkSE5H3PXp88R3y/JbSMuFJwWwS2AGwYd =L+6w -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl9yPpwTHGJyb29uaWVA a2VybmVsLm9yZwAKCRAk1otyXVSH0PkDB/9ybt51NqJWyU3JaleY7otD2QvCmvl6 2dzpDncfjYZ8GOhvju74BQM9h/m9EHzb5FQ1yLMKEeICXZwxkDgHiqMLYLN1e6wx ug5U6lvbT1TmeBa7IJYNNSGH2BKeIDM5Hm2zVvMpEJhF2Y9uAE0HqxjGL3CfbUOv R2o2K3wgax83FfX86wmYNgkkp4Ri1qviD1Jr90zzFZRr0FAjiyrFHXdfdvK/wUx1 5n9wg+aIehQr1a8cKYQaqWd3HZR6pofmOj1cO4n/By+VEYRWaVds8OKUrqimZ2mE moX9+ooY3eFdmS6kgtA31bgBFjKxfMNaTzTa4B3kikmxSOKMupQejBn9 =G3GG -----END PGP SIGNATURE----- Merge tag 'regmap-field-bulk-api' into regmap-5.10 regmap: Add a bulk field API Useful for devices with many fields.
This commit is contained in:
commit
d05199af72
@ -1254,6 +1254,106 @@ struct regmap_field *devm_regmap_field_alloc(struct device *dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_regmap_field_alloc);
|
||||
|
||||
|
||||
/**
|
||||
* regmap_field_bulk_alloc() - Allocate and initialise a bulk register field.
|
||||
*
|
||||
* @regmap: regmap bank in which this register field is located.
|
||||
* @rm_field: regmap register fields within the bank.
|
||||
* @reg_field: Register fields within the bank.
|
||||
* @num_fields: Number of register fields.
|
||||
*
|
||||
* The return value will be an -ENOMEM on error or zero for success.
|
||||
* Newly allocated regmap_fields should be freed by calling
|
||||
* regmap_field_bulk_free()
|
||||
*/
|
||||
int regmap_field_bulk_alloc(struct regmap *regmap,
|
||||
struct regmap_field **rm_field,
|
||||
struct reg_field *reg_field,
|
||||
int num_fields)
|
||||
{
|
||||
struct regmap_field *rf;
|
||||
int i;
|
||||
|
||||
rf = kcalloc(num_fields, sizeof(*rf), GFP_KERNEL);
|
||||
if (!rf)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_fields; i++) {
|
||||
regmap_field_init(&rf[i], regmap, reg_field[i]);
|
||||
rm_field[i] = &rf[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_field_bulk_alloc);
|
||||
|
||||
/**
|
||||
* devm_regmap_field_bulk_alloc() - Allocate and initialise a bulk register
|
||||
* fields.
|
||||
*
|
||||
* @dev: Device that will be interacted with
|
||||
* @regmap: regmap bank in which this register field is located.
|
||||
* @rm_field: regmap register fields within the bank.
|
||||
* @reg_field: Register fields within the bank.
|
||||
* @num_fields: Number of register fields.
|
||||
*
|
||||
* The return value will be an -ENOMEM on error or zero for success.
|
||||
* Newly allocated regmap_fields will be automatically freed by the
|
||||
* device management code.
|
||||
*/
|
||||
int devm_regmap_field_bulk_alloc(struct device *dev,
|
||||
struct regmap *regmap,
|
||||
struct regmap_field **rm_field,
|
||||
struct reg_field *reg_field,
|
||||
int num_fields)
|
||||
{
|
||||
struct regmap_field *rf;
|
||||
int i;
|
||||
|
||||
rf = devm_kcalloc(dev, num_fields, sizeof(*rf), GFP_KERNEL);
|
||||
if (!rf)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_fields; i++) {
|
||||
regmap_field_init(&rf[i], regmap, reg_field[i]);
|
||||
rm_field[i] = &rf[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_regmap_field_bulk_alloc);
|
||||
|
||||
/**
|
||||
* regmap_field_bulk_free() - Free register field allocated using
|
||||
* regmap_field_bulk_alloc.
|
||||
*
|
||||
* @field: regmap fields which should be freed.
|
||||
*/
|
||||
void regmap_field_bulk_free(struct regmap_field *field)
|
||||
{
|
||||
kfree(field);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_field_bulk_free);
|
||||
|
||||
/**
|
||||
* devm_regmap_field_bulk_free() - Free a bulk register field allocated using
|
||||
* devm_regmap_field_bulk_alloc.
|
||||
*
|
||||
* @dev: Device that will be interacted with
|
||||
* @field: regmap field which should be freed.
|
||||
*
|
||||
* Free register field allocated using devm_regmap_field_bulk_alloc(). Usually
|
||||
* drivers need not call this function, as the memory allocated via devm
|
||||
* will be freed as per device-driver life-cycle.
|
||||
*/
|
||||
void devm_regmap_field_bulk_free(struct device *dev,
|
||||
struct regmap_field *field)
|
||||
{
|
||||
devm_kfree(dev, field);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_regmap_field_bulk_free);
|
||||
|
||||
/**
|
||||
* devm_regmap_field_free() - Free a register field allocated using
|
||||
* devm_regmap_field_alloc.
|
||||
|
@ -1189,6 +1189,17 @@ struct regmap_field *devm_regmap_field_alloc(struct device *dev,
|
||||
struct regmap *regmap, struct reg_field reg_field);
|
||||
void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
|
||||
|
||||
int regmap_field_bulk_alloc(struct regmap *regmap,
|
||||
struct regmap_field **rm_field,
|
||||
struct reg_field *reg_field,
|
||||
int num_fields);
|
||||
void regmap_field_bulk_free(struct regmap_field *field);
|
||||
int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap,
|
||||
struct regmap_field **field,
|
||||
struct reg_field *reg_field, int num_fields);
|
||||
void devm_regmap_field_bulk_free(struct device *dev,
|
||||
struct regmap_field *field);
|
||||
|
||||
int regmap_field_read(struct regmap_field *field, unsigned int *val);
|
||||
int regmap_field_update_bits_base(struct regmap_field *field,
|
||||
unsigned int mask, unsigned int val,
|
||||
|
Loading…
Reference in New Issue
Block a user