@@ -15,6 +15,7 @@
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/wait.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -546,7 +547,6 @@ static int amd_sdw_port_enable(struct sdw_bus *bus,
static int sdw_master_read_amd_prop(struct sdw_bus *bus)
{
struct amd_sdw_manager *amd_manager = to_amd_sdw(bus);
- struct fwnode_handle *link;
struct sdw_master_prop *prop;
u32 quirk_mask = 0;
u32 wake_en_mask = 0;
@@ -556,7 +556,9 @@ static int sdw_master_read_amd_prop(struct sdw_bus *bus)
prop = &bus->prop;
/* Find manager handle */
snprintf(name, sizeof(name), "mipi-sdw-link-%d-subproperties", bus->link_id);
- link = device_get_named_child_node(bus->dev, name);
+
+ struct fwnode_handle *link __free(fwnode_handle)
+ = device_get_named_child_node(bus->dev, name);
if (!link) {
dev_err(bus->dev, "Manager node %s not found\n", name);
return -EIO;
@@ -571,9 +573,6 @@ static int sdw_master_read_amd_prop(struct sdw_bus *bus)
amd_manager->wake_en_mask = wake_en_mask;
fwnode_property_read_u32(link, "amd-sdw-power-mode", &power_mode_mask);
amd_manager->power_mode_mask = power_mode_mask;
-
- fwnode_handle_put(link);
-
return 0;
}
@@ -14,6 +14,7 @@
#include <linux/auxiliary_bus.h>
#include <sound/pcm_params.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <sound/soc.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
@@ -123,7 +124,6 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
{
struct sdw_master_prop *prop = &bus->prop;
struct sdw_intel_prop *intel_prop;
- struct fwnode_handle *link;
char name[32];
u32 quirk_mask;
@@ -131,7 +131,8 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
snprintf(name, sizeof(name),
"mipi-sdw-link-%d-subproperties", bus->link_id);
- link = device_get_named_child_node(bus->dev, name);
+ struct fwnode_handle *link __free(fwnode_handle)
+ = device_get_named_child_node(bus->dev, name);
if (!link) {
dev_err(bus->dev, "Master node %s not found\n", name);
return -EIO;
@@ -155,10 +156,8 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY;
intel_prop = devm_kzalloc(bus->dev, sizeof(*intel_prop), GFP_KERNEL);
- if (!intel_prop) {
- fwnode_handle_put(link);
+ if (!intel_prop)
return -ENOMEM;
- }
/* initialize with hardware defaults, in case the properties are not found */
intel_prop->clde = 0x0;
@@ -205,9 +204,6 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
intel_prop->doais,
intel_prop->dodse,
intel_prop->dods);
-
- fwnode_handle_put(link);
-
return 0;
}
@@ -30,7 +30,6 @@
int sdw_master_read_prop(struct sdw_bus *bus)
{
struct sdw_master_prop *prop = &bus->prop;
- struct fwnode_handle *link;
char name[32];
int nval, i;
@@ -42,7 +41,8 @@ int sdw_master_read_prop(struct sdw_bus *bus)
snprintf(name, sizeof(name),
"mipi-sdw-link-%d-subproperties", bus->link_id);
- link = device_get_named_child_node(bus->dev, name);
+ struct fwnode_handle *link __free(fwnode_handle)
+ = device_get_named_child_node(bus->dev, name);
if (!link) {
dev_err(bus->dev, "Master node %s not found\n", name);
return -EIO;
@@ -66,10 +66,8 @@ int sdw_master_read_prop(struct sdw_bus *bus)
prop->clk_freq = devm_kcalloc(bus->dev, prop->num_clk_freq,
sizeof(*prop->clk_freq),
GFP_KERNEL);
- if (!prop->clk_freq) {
- fwnode_handle_put(link);
+ if (!prop->clk_freq)
return -ENOMEM;
- }
fwnode_property_read_u32_array(link,
"mipi-sdw-clock-frequencies-supported",
@@ -94,10 +92,8 @@ int sdw_master_read_prop(struct sdw_bus *bus)
prop->clk_gears = devm_kcalloc(bus->dev, prop->num_clk_gears,
sizeof(*prop->clk_gears),
GFP_KERNEL);
- if (!prop->clk_gears) {
- fwnode_handle_put(link);
+ if (!prop->clk_gears)
return -ENOMEM;
- }
fwnode_property_read_u32_array(link,
"mipi-sdw-supported-clock-gears",
@@ -119,9 +115,6 @@ int sdw_master_read_prop(struct sdw_bus *bus)
fwnode_property_read_u32(link, "mipi-sdw-command-error-threshold",
&prop->err_threshold);
-
- fwnode_handle_put(link);
-
return 0;
}
EXPORT_SYMBOL(sdw_master_read_prop);
@@ -169,7 +162,6 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
struct sdw_dpn_prop *dpn, int count, int ports,
char *type)
{
- struct fwnode_handle *node;
u32 bit, i = 0;
int nval;
unsigned long addr;
@@ -185,7 +177,8 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
dpn[i].num = bit;
- node = device_get_named_child_node(&slave->dev, name);
+ struct fwnode_handle *node __free(fwnode_handle)
+ = device_get_named_child_node(&slave->dev, name);
if (!node) {
dev_err(&slave->dev, "%s dpN not found\n", name);
return -EIO;
@@ -203,10 +196,8 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
dpn[i].num_words,
sizeof(*dpn[i].words),
GFP_KERNEL);
- if (!dpn[i].words) {
- fwnode_handle_put(node);
+ if (!dpn[i].words)
return -ENOMEM;
- }
fwnode_property_read_u32_array(node,
"mipi-sdw-port-wordlength-configs",
@@ -244,10 +235,8 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
dpn[i].num_channels,
sizeof(*dpn[i].channels),
GFP_KERNEL);
- if (!dpn[i].channels) {
- fwnode_handle_put(node);
+ if (!dpn[i].channels)
return -ENOMEM;
- }
fwnode_property_read_u32_array(node,
"mipi-sdw-channel-number-list",
@@ -261,10 +250,8 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
dpn[i].num_ch_combinations,
sizeof(*dpn[i].ch_combinations),
GFP_KERNEL);
- if (!dpn[i].ch_combinations) {
- fwnode_handle_put(node);
+ if (!dpn[i].ch_combinations)
return -ENOMEM;
- }
fwnode_property_read_u32_array(node,
"mipi-sdw-channel-combination-list",
@@ -286,8 +273,6 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
/* TODO: Read audio mode */
- fwnode_handle_put(node);
-
i++;
}
@@ -302,7 +287,6 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
{
struct sdw_slave_prop *prop = &slave->prop;
struct device *dev = &slave->dev;
- struct fwnode_handle *port;
int nval;
device_property_read_u32(dev, "mipi-sdw-sw-interface-revision",
@@ -355,21 +339,21 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
&prop->sink_ports);
/* Read dp0 properties */
- port = device_get_named_child_node(dev, "mipi-sdw-dp-0-subproperties");
- if (!port) {
- dev_dbg(dev, "DP0 node not found!!\n");
- } else {
- prop->dp0_prop = devm_kzalloc(&slave->dev,
- sizeof(*prop->dp0_prop),
- GFP_KERNEL);
- if (!prop->dp0_prop) {
- fwnode_handle_put(port);
- return -ENOMEM;
- }
-
- sdw_slave_read_dp0(slave, port, prop->dp0_prop);
+ {
+ struct fwnode_handle *port __free(fwnode_handle)
+ = device_get_named_child_node(dev,
+ "mipi-sdw-dp-0-subproperties");
+ if (!port) {
+ dev_dbg(dev, "DP0 node not found!!\n");
+ } else {
+ prop->dp0_prop = devm_kzalloc(&slave->dev,
+ sizeof(*prop->dp0_prop),
+ GFP_KERNEL);
+ if (!prop->dp0_prop)
+ return -ENOMEM;
- fwnode_handle_put(port);
+ sdw_slave_read_dp0(slave, port, prop->dp0_prop);
+ }
}
/*