Skip to content

Commit

Permalink
Merge tag 'devprop-5.14-rc1' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/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
  • Loading branch information
torvalds committed Jun 29, 2021
2 parents 72ad9f9 + fb38f31 commit 349a2d5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/arm64/iort.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ static void iort_named_component_init(struct device *dev,
FIELD_GET(ACPI_IORT_NC_PASID_BITS,
nc->node_flags));

if (device_add_properties(dev, props))
if (device_create_managed_software_node(dev, props, NULL))
dev_warn(dev, "Could not add device properties\n");
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
*
* Return false if DMA is not supported. Otherwise, return true
*/
bool acpi_dma_supported(struct acpi_device *adev)
bool acpi_dma_supported(const struct acpi_device *adev)
{
if (!adev)
return false;
Expand Down
31 changes: 14 additions & 17 deletions drivers/base/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct fwnode_handle *dev_fwnode(struct device *dev)
{
return IS_ENABLED(CONFIG_OF) && dev->of_node ?
&dev->of_node->fwnode : dev->fwnode;
of_fwnode_handle(dev->of_node) : dev->fwnode;
}
EXPORT_SYMBOL_GPL(dev_fwnode);

Expand Down Expand Up @@ -759,13 +759,8 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);
struct fwnode_handle *device_get_next_child_node(struct device *dev,
struct fwnode_handle *child)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
struct fwnode_handle *fwnode = NULL, *next;

if (dev->of_node)
fwnode = &dev->of_node->fwnode;
else if (adev)
fwnode = acpi_fwnode_handle(adev);
const struct fwnode_handle *fwnode = dev_fwnode(dev);
struct fwnode_handle *next;

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

bool device_dma_supported(struct device *dev)
{
const struct fwnode_handle *fwnode = dev_fwnode(dev);

/* For DT, this is always supported.
* For ACPI, this depends on CCA, which
* is determined by the acpi_dma_supported().
*/
if (IS_ENABLED(CONFIG_OF) && dev->of_node)
if (is_of_node(fwnode))
return true;

return acpi_dma_supported(ACPI_COMPANION(dev));
return acpi_dma_supported(to_acpi_device_node(fwnode));
}
EXPORT_SYMBOL_GPL(device_dma_supported);

enum dev_dma_attr device_get_dma_attr(struct device *dev)
{
const struct fwnode_handle *fwnode = dev_fwnode(dev);
enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED;

if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
if (of_dma_is_coherent(dev->of_node))
if (is_of_node(fwnode)) {
if (of_dma_is_coherent(to_of_node(fwnode)))
attr = DEV_DMA_COHERENT;
else
attr = DEV_DMA_NON_COHERENT;
} else
attr = acpi_get_dma_attr(ACPI_COMPANION(dev));
attr = acpi_get_dma_attr(to_acpi_device_node(fwnode));

return attr;
}
Expand Down Expand Up @@ -1007,14 +1005,13 @@ EXPORT_SYMBOL(device_get_mac_address);
* Returns Linux IRQ number on success. Other values are determined
* accordingly to acpi_/of_ irq_get() operation.
*/
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index)
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
{
struct device_node *of_node = to_of_node(fwnode);
struct resource res;
int ret;

if (IS_ENABLED(CONFIG_OF) && of_node)
return of_irq_get(of_node, index);
if (is_of_node(fwnode))
return of_irq_get(to_of_node(fwnode), index);

ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ struct acpi_pci_root {

/* helper */

bool acpi_dma_supported(struct acpi_device *adev);
bool acpi_dma_supported(const struct acpi_device *adev);
enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset,
u64 *size);
Expand Down
8 changes: 4 additions & 4 deletions include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
return false;
}

static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
static inline struct acpi_device *to_acpi_device_node(const struct fwnode_handle *fwnode)
{
return NULL;
}
Expand All @@ -776,12 +776,12 @@ static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
return false;
}

static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
static inline struct acpi_data_node *to_acpi_data_node(const struct fwnode_handle *fwnode)
{
return NULL;
}

static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
const char *name)
{
return false;
Expand Down Expand Up @@ -912,7 +912,7 @@ acpi_create_platform_device(struct acpi_device *adev,
return NULL;
}

static inline bool acpi_dma_supported(struct acpi_device *adev)
static inline bool acpi_dma_supported(const struct acpi_device *adev)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev,
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
void fwnode_handle_put(struct fwnode_handle *fwnode);

int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);

unsigned int device_get_child_node_count(struct device *dev);

Expand Down

0 comments on commit 349a2d5

Please sign in to comment.