Skip to content

Commit d516840

Browse files
committed
Merge tag 'regmap-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap updates from Mark Brown: "This release we've seen a couple of updates to make some DT based APIs use fwnode instead, allowing their use with ACPI systems, and a few cleanups" * tag 'regmap-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: fix duplicated word in <linux/regmap.h> regmap: Switch to use fwnode instead of OF one regmap-irq: use fwnode instead of device node in add_irq_chip() regmap: remove stray space regmap: convert all regmap_update_bits() and co. macros to static inlines
2 parents b171373 + c9fadf2 commit d516840

File tree

3 files changed

+248
-83
lines changed

3 files changed

+248
-83
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ static const struct irq_domain_ops regmap_domain_ops = {
541541
};
542542

543543
/**
544-
* regmap_add_irq_chip_np() - Use standard regmap IRQ controller handling
544+
* regmap_add_irq_chip_fwnode() - Use standard regmap IRQ controller handling
545545
*
546-
* @np: The device_node where the IRQ domain should be added to.
546+
* @fwnode: The firmware node where the IRQ domain should be added to.
547547
* @map: The regmap for the device.
548548
* @irq: The IRQ the device uses to signal interrupts.
549549
* @irq_flags: The IRQF_ flags to use for the primary interrupt.
@@ -557,10 +557,11 @@ static const struct irq_domain_ops regmap_domain_ops = {
557557
* register cache. The chip driver is responsible for restoring the
558558
* register values used by the IRQ controller over suspend and resume.
559559
*/
560-
int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq,
561-
int irq_flags, int irq_base,
562-
const struct regmap_irq_chip *chip,
563-
struct regmap_irq_chip_data **data)
560+
int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
561+
struct regmap *map, int irq,
562+
int irq_flags, int irq_base,
563+
const struct regmap_irq_chip *chip,
564+
struct regmap_irq_chip_data **data)
564565
{
565566
struct regmap_irq_chip_data *d;
566567
int i;
@@ -771,10 +772,12 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq,
771772
}
772773

773774
if (irq_base)
774-
d->domain = irq_domain_add_legacy(np, chip->num_irqs, irq_base,
775+
d->domain = irq_domain_add_legacy(to_of_node(fwnode),
776+
chip->num_irqs, irq_base,
775777
0, &regmap_domain_ops, d);
776778
else
777-
d->domain = irq_domain_add_linear(np, chip->num_irqs,
779+
d->domain = irq_domain_add_linear(to_of_node(fwnode),
780+
chip->num_irqs,
778781
&regmap_domain_ops, d);
779782
if (!d->domain) {
780783
dev_err(map->dev, "Failed to create IRQ domain\n");
@@ -808,7 +811,7 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq,
808811
kfree(d);
809812
return ret;
810813
}
811-
EXPORT_SYMBOL_GPL(regmap_add_irq_chip_np);
814+
EXPORT_SYMBOL_GPL(regmap_add_irq_chip_fwnode);
812815

813816
/**
814817
* regmap_add_irq_chip() - Use standard regmap IRQ controller handling
@@ -822,15 +825,15 @@ EXPORT_SYMBOL_GPL(regmap_add_irq_chip_np);
822825
*
823826
* Returns 0 on success or an errno on failure.
824827
*
825-
* This is the same as regmap_add_irq_chip_np, except that the device
828+
* This is the same as regmap_add_irq_chip_fwnode, except that the firmware
826829
* node of the regmap is used.
827830
*/
828831
int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
829832
int irq_base, const struct regmap_irq_chip *chip,
830833
struct regmap_irq_chip_data **data)
831834
{
832-
return regmap_add_irq_chip_np(map->dev->of_node, map, irq, irq_flags,
833-
irq_base, chip, data);
835+
return regmap_add_irq_chip_fwnode(dev_fwnode(map->dev), map, irq,
836+
irq_flags, irq_base, chip, data);
834837
}
835838
EXPORT_SYMBOL_GPL(regmap_add_irq_chip);
836839

@@ -899,10 +902,10 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data)
899902
}
900903

901904
/**
902-
* devm_regmap_add_irq_chip_np() - Resource manager regmap_add_irq_chip_np()
905+
* devm_regmap_add_irq_chip_fwnode() - Resource managed regmap_add_irq_chip_fwnode()
903906
*
904907
* @dev: The device pointer on which irq_chip belongs to.
905-
* @np: The device_node where the IRQ domain should be added to.
908+
* @fwnode: The firmware node where the IRQ domain should be added to.
906909
* @map: The regmap for the device.
907910
* @irq: The IRQ the device uses to signal interrupts
908911
* @irq_flags: The IRQF_ flags to use for the primary interrupt.
@@ -915,11 +918,12 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data)
915918
* The &regmap_irq_chip_data will be automatically released when the device is
916919
* unbound.
917920
*/
918-
int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np,
919-
struct regmap *map, int irq, int irq_flags,
920-
int irq_base,
921-
const struct regmap_irq_chip *chip,
922-
struct regmap_irq_chip_data **data)
921+
int devm_regmap_add_irq_chip_fwnode(struct device *dev,
922+
struct fwnode_handle *fwnode,
923+
struct regmap *map, int irq,
924+
int irq_flags, int irq_base,
925+
const struct regmap_irq_chip *chip,
926+
struct regmap_irq_chip_data **data)
923927
{
924928
struct regmap_irq_chip_data **ptr, *d;
925929
int ret;
@@ -929,8 +933,8 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np,
929933
if (!ptr)
930934
return -ENOMEM;
931935

932-
ret = regmap_add_irq_chip_np(np, map, irq, irq_flags, irq_base,
933-
chip, &d);
936+
ret = regmap_add_irq_chip_fwnode(fwnode, map, irq, irq_flags, irq_base,
937+
chip, &d);
934938
if (ret < 0) {
935939
devres_free(ptr);
936940
return ret;
@@ -941,7 +945,7 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np,
941945
*data = d;
942946
return 0;
943947
}
944-
EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip_np);
948+
EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip_fwnode);
945949

946950
/**
947951
* devm_regmap_add_irq_chip() - Resource manager regmap_add_irq_chip()
@@ -964,8 +968,9 @@ int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
964968
const struct regmap_irq_chip *chip,
965969
struct regmap_irq_chip_data **data)
966970
{
967-
return devm_regmap_add_irq_chip_np(dev, map->dev->of_node, map, irq,
968-
irq_flags, irq_base, chip, data);
971+
return devm_regmap_add_irq_chip_fwnode(dev, dev_fwnode(map->dev), map,
972+
irq, irq_flags, irq_base, chip,
973+
data);
969974
}
970975
EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip);
971976

drivers/base/regmap/regmap.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/export.h>
1212
#include <linux/mutex.h>
1313
#include <linux/err.h>
14-
#include <linux/of.h>
14+
#include <linux/property.h>
1515
#include <linux/rbtree.h>
1616
#include <linux/sched.h>
1717
#include <linux/delay.h>
@@ -631,7 +631,7 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
631631
const struct regmap_bus *bus,
632632
const struct regmap_config *config)
633633
{
634-
struct device_node *np;
634+
struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
635635
enum regmap_endian endian;
636636

637637
/* Retrieve the endianness specification from the regmap config */
@@ -641,22 +641,17 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
641641
if (endian != REGMAP_ENDIAN_DEFAULT)
642642
return endian;
643643

644-
/* If the dev and dev->of_node exist try to get endianness from DT */
645-
if (dev && dev->of_node) {
646-
np = dev->of_node;
647-
648-
/* Parse the device's DT node for an endianness specification */
649-
if (of_property_read_bool(np, "big-endian"))
650-
endian = REGMAP_ENDIAN_BIG;
651-
else if (of_property_read_bool(np, "little-endian"))
652-
endian = REGMAP_ENDIAN_LITTLE;
653-
else if (of_property_read_bool(np, "native-endian"))
654-
endian = REGMAP_ENDIAN_NATIVE;
655-
656-
/* If the endianness was specified in DT, use that */
657-
if (endian != REGMAP_ENDIAN_DEFAULT)
658-
return endian;
659-
}
644+
/* If the firmware node exist try to get endianness from it */
645+
if (fwnode_property_read_bool(fwnode, "big-endian"))
646+
endian = REGMAP_ENDIAN_BIG;
647+
else if (fwnode_property_read_bool(fwnode, "little-endian"))
648+
endian = REGMAP_ENDIAN_LITTLE;
649+
else if (fwnode_property_read_bool(fwnode, "native-endian"))
650+
endian = REGMAP_ENDIAN_NATIVE;
651+
652+
/* If the endianness was specified in fwnode, use that */
653+
if (endian != REGMAP_ENDIAN_DEFAULT)
654+
return endian;
660655

661656
/* Retrieve the endianness specification from the bus config */
662657
if (bus && bus->val_format_endian_default)
@@ -2024,7 +2019,7 @@ EXPORT_SYMBOL_GPL(regmap_field_update_bits_base);
20242019
* A value of zero will be returned on success, a negative errno will
20252020
* be returned in error cases.
20262021
*/
2027-
int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
2022+
int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
20282023
unsigned int mask, unsigned int val,
20292024
bool *change, bool async, bool force)
20302025
{

0 commit comments

Comments
 (0)