Skip to content

Commit 349a2d5

Browse files
committed
Merge tag 'devprop-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "These unify device properties access in some pieces of code and make related changes. Specifics: - Handle device properties with software node API in the ACPI IORT table parsing code (Heikki Krogerus). - Unify of_node access in the common device properties code, constify the acpi_dma_supported() argument pointer and fix up CONFIG_ACPI=n stubs of some functions related to device properties (Andy Shevchenko)" * tag 'devprop-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: device property: Unify access to of_node ACPI: scan: Constify acpi_dma_supported() helper function ACPI: property: Constify stubs for CONFIG_ACPI=n case ACPI: IORT: Handle device properties with software node API device property: Retrieve fwnode from of_node via accessor
2 parents 72ad9f9 + fb38f31 commit 349a2d5

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

drivers/acpi/arm64/iort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ static void iort_named_component_init(struct device *dev,
976976
FIELD_GET(ACPI_IORT_NC_PASID_BITS,
977977
nc->node_flags));
978978

979-
if (device_add_properties(dev, props))
979+
if (device_create_managed_software_node(dev, props, NULL))
980980
dev_warn(dev, "Could not add device properties\n");
981981
}
982982

drivers/acpi/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
14111411
*
14121412
* Return false if DMA is not supported. Otherwise, return true
14131413
*/
1414-
bool acpi_dma_supported(struct acpi_device *adev)
1414+
bool acpi_dma_supported(const struct acpi_device *adev)
14151415
{
14161416
if (!adev)
14171417
return false;

drivers/base/property.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
struct fwnode_handle *dev_fwnode(struct device *dev)
2222
{
2323
return IS_ENABLED(CONFIG_OF) && dev->of_node ?
24-
&dev->of_node->fwnode : dev->fwnode;
24+
of_fwnode_handle(dev->of_node) : dev->fwnode;
2525
}
2626
EXPORT_SYMBOL_GPL(dev_fwnode);
2727

@@ -759,13 +759,8 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);
759759
struct fwnode_handle *device_get_next_child_node(struct device *dev,
760760
struct fwnode_handle *child)
761761
{
762-
struct acpi_device *adev = ACPI_COMPANION(dev);
763-
struct fwnode_handle *fwnode = NULL, *next;
764-
765-
if (dev->of_node)
766-
fwnode = &dev->of_node->fwnode;
767-
else if (adev)
768-
fwnode = acpi_fwnode_handle(adev);
762+
const struct fwnode_handle *fwnode = dev_fwnode(dev);
763+
struct fwnode_handle *next;
769764

770765
/* Try to find a child in primary fwnode */
771766
next = fwnode_get_next_child_node(fwnode, child);
@@ -868,28 +863,31 @@ EXPORT_SYMBOL_GPL(device_get_child_node_count);
868863

869864
bool device_dma_supported(struct device *dev)
870865
{
866+
const struct fwnode_handle *fwnode = dev_fwnode(dev);
867+
871868
/* For DT, this is always supported.
872869
* For ACPI, this depends on CCA, which
873870
* is determined by the acpi_dma_supported().
874871
*/
875-
if (IS_ENABLED(CONFIG_OF) && dev->of_node)
872+
if (is_of_node(fwnode))
876873
return true;
877874

878-
return acpi_dma_supported(ACPI_COMPANION(dev));
875+
return acpi_dma_supported(to_acpi_device_node(fwnode));
879876
}
880877
EXPORT_SYMBOL_GPL(device_dma_supported);
881878

882879
enum dev_dma_attr device_get_dma_attr(struct device *dev)
883880
{
881+
const struct fwnode_handle *fwnode = dev_fwnode(dev);
884882
enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED;
885883

886-
if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
887-
if (of_dma_is_coherent(dev->of_node))
884+
if (is_of_node(fwnode)) {
885+
if (of_dma_is_coherent(to_of_node(fwnode)))
888886
attr = DEV_DMA_COHERENT;
889887
else
890888
attr = DEV_DMA_NON_COHERENT;
891889
} else
892-
attr = acpi_get_dma_attr(ACPI_COMPANION(dev));
890+
attr = acpi_get_dma_attr(to_acpi_device_node(fwnode));
893891

894892
return attr;
895893
}
@@ -1007,14 +1005,13 @@ EXPORT_SYMBOL(device_get_mac_address);
10071005
* Returns Linux IRQ number on success. Other values are determined
10081006
* accordingly to acpi_/of_ irq_get() operation.
10091007
*/
1010-
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index)
1008+
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
10111009
{
1012-
struct device_node *of_node = to_of_node(fwnode);
10131010
struct resource res;
10141011
int ret;
10151012

1016-
if (IS_ENABLED(CONFIG_OF) && of_node)
1017-
return of_irq_get(of_node, index);
1013+
if (is_of_node(fwnode))
1014+
return of_irq_get(to_of_node(fwnode), index);
10181015

10191016
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
10201017
if (ret)

include/acpi/acpi_bus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ struct acpi_pci_root {
590590

591591
/* helper */
592592

593-
bool acpi_dma_supported(struct acpi_device *adev);
593+
bool acpi_dma_supported(const struct acpi_device *adev);
594594
enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
595595
int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset,
596596
u64 *size);

include/linux/acpi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
766766
return false;
767767
}
768768

769-
static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
769+
static inline struct acpi_device *to_acpi_device_node(const struct fwnode_handle *fwnode)
770770
{
771771
return NULL;
772772
}
@@ -776,12 +776,12 @@ static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
776776
return false;
777777
}
778778

779-
static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
779+
static inline struct acpi_data_node *to_acpi_data_node(const struct fwnode_handle *fwnode)
780780
{
781781
return NULL;
782782
}
783783

784-
static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
784+
static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
785785
const char *name)
786786
{
787787
return false;
@@ -912,7 +912,7 @@ acpi_create_platform_device(struct acpi_device *adev,
912912
return NULL;
913913
}
914914

915-
static inline bool acpi_dma_supported(struct acpi_device *adev)
915+
static inline bool acpi_dma_supported(const struct acpi_device *adev)
916916
{
917917
return false;
918918
}

include/linux/property.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev,
119119
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
120120
void fwnode_handle_put(struct fwnode_handle *fwnode);
121121

122-
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
122+
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
123123

124124
unsigned int device_get_child_node_count(struct device *dev);
125125

0 commit comments

Comments
 (0)