mirror of https://gitee.com/openkylin/linux.git
soundwire: bus: clarify dev_err/dbg device references
The SoundWire bus code confuses bus and Slave device levels for dev_err/dbg logs. That's not impacting functionality but the accuracy of kernel logs. We should only use bus->dev for bus-level operations and handling of Device0. For all other logs where the device number is not zero, we should use &slave->dev to provide more precisions to the user/integrator. Reported-by: Rander Wang <rander.wang@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20210122070634.12825-10-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
973794e856
commit
6d7a1ff71c
|
@ -638,6 +638,7 @@ static int sdw_get_device_num(struct sdw_slave *slave)
|
|||
|
||||
static int sdw_assign_device_num(struct sdw_slave *slave)
|
||||
{
|
||||
struct sdw_bus *bus = slave->bus;
|
||||
int ret, dev_num;
|
||||
bool new_device = false;
|
||||
|
||||
|
@ -648,7 +649,7 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
|
|||
dev_num = sdw_get_device_num(slave);
|
||||
mutex_unlock(&slave->bus->bus_lock);
|
||||
if (dev_num < 0) {
|
||||
dev_err(slave->bus->dev, "Get dev_num failed: %d\n",
|
||||
dev_err(bus->dev, "Get dev_num failed: %d\n",
|
||||
dev_num);
|
||||
return dev_num;
|
||||
}
|
||||
|
@ -661,7 +662,7 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
|
|||
}
|
||||
|
||||
if (!new_device)
|
||||
dev_dbg(slave->bus->dev,
|
||||
dev_dbg(bus->dev,
|
||||
"Slave already registered, reusing dev_num:%d\n",
|
||||
slave->dev_num);
|
||||
|
||||
|
@ -671,7 +672,7 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
|
|||
|
||||
ret = sdw_write_no_pm(slave, SDW_SCP_DEVNUMBER, dev_num);
|
||||
if (ret < 0) {
|
||||
dev_err(&slave->dev, "Program device_num %d failed: %d\n",
|
||||
dev_err(bus->dev, "Program device_num %d failed: %d\n",
|
||||
dev_num, ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -749,7 +750,7 @@ static int sdw_program_device_num(struct sdw_bus *bus)
|
|||
*/
|
||||
ret = sdw_assign_device_num(slave);
|
||||
if (ret) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(bus->dev,
|
||||
"Assign dev_num failed:%d\n",
|
||||
ret);
|
||||
return ret;
|
||||
|
@ -789,9 +790,11 @@ static int sdw_program_device_num(struct sdw_bus *bus)
|
|||
static void sdw_modify_slave_status(struct sdw_slave *slave,
|
||||
enum sdw_slave_status status)
|
||||
{
|
||||
mutex_lock(&slave->bus->bus_lock);
|
||||
struct sdw_bus *bus = slave->bus;
|
||||
|
||||
dev_vdbg(&slave->dev,
|
||||
mutex_lock(&bus->bus_lock);
|
||||
|
||||
dev_vdbg(bus->dev,
|
||||
"%s: changing status slave %d status %d new status %d\n",
|
||||
__func__, slave->dev_num, slave->status, status);
|
||||
|
||||
|
@ -812,7 +815,7 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,
|
|||
complete(&slave->enumeration_complete);
|
||||
}
|
||||
slave->status = status;
|
||||
mutex_unlock(&slave->bus->bus_lock);
|
||||
mutex_unlock(&bus->bus_lock);
|
||||
}
|
||||
|
||||
static enum sdw_clk_stop_mode sdw_get_clk_stop_mode(struct sdw_slave *slave)
|
||||
|
@ -1138,7 +1141,7 @@ int sdw_configure_dpn_intr(struct sdw_slave *slave,
|
|||
|
||||
ret = sdw_update(slave, addr, (mask | SDW_DPN_INT_PORT_READY), val);
|
||||
if (ret < 0)
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DPN_INTMASK write failed:%d\n", val);
|
||||
|
||||
return ret;
|
||||
|
@ -1269,7 +1272,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave)
|
|||
/* Enable SCP interrupts */
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1, val, val);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INTMASK1 write failed:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1284,7 +1287,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave)
|
|||
|
||||
ret = sdw_update_no_pm(slave, SDW_DP0_INTMASK, val, val);
|
||||
if (ret < 0)
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INTMASK read failed:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1296,7 +1299,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status)
|
|||
|
||||
status = sdw_read_no_pm(slave, SDW_DP0_INT);
|
||||
if (status < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INT read failed:%d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
@ -1335,7 +1338,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status)
|
|||
/* clear the interrupts but don't touch reserved and SDCA_CASCADE fields */
|
||||
ret = sdw_write_no_pm(slave, SDW_DP0_INT, clear);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INT write failed:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1343,7 +1346,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status)
|
|||
/* Read DP0 interrupt again */
|
||||
status2 = sdw_read_no_pm(slave, SDW_DP0_INT);
|
||||
if (status2 < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INT read failed:%d\n", status2);
|
||||
return status2;
|
||||
}
|
||||
|
@ -1356,7 +1359,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status)
|
|||
} while ((status & SDW_DP0_INTERRUPTS) && (count < SDW_READ_INTR_CLEAR_RETRY));
|
||||
|
||||
if (count == SDW_READ_INTR_CLEAR_RETRY)
|
||||
dev_warn(slave->bus->dev, "Reached MAX_RETRY on DP0 read\n");
|
||||
dev_warn(&slave->dev, "Reached MAX_RETRY on DP0 read\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1374,7 +1377,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave,
|
|||
addr = SDW_DPN_INT(port);
|
||||
status = sdw_read_no_pm(slave, addr);
|
||||
if (status < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DPN_INT read failed:%d\n", status);
|
||||
|
||||
return status;
|
||||
|
@ -1408,7 +1411,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave,
|
|||
/* clear the interrupt but don't touch reserved fields */
|
||||
ret = sdw_write_no_pm(slave, addr, clear);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DPN_INT write failed:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1416,7 +1419,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave,
|
|||
/* Read DPN interrupt again */
|
||||
status2 = sdw_read_no_pm(slave, addr);
|
||||
if (status2 < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DPN_INT read failed:%d\n", status2);
|
||||
return status2;
|
||||
}
|
||||
|
@ -1429,7 +1432,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave,
|
|||
} while ((status & SDW_DPN_INTERRUPTS) && (count < SDW_READ_INTR_CLEAR_RETRY));
|
||||
|
||||
if (count == SDW_READ_INTR_CLEAR_RETRY)
|
||||
dev_warn(slave->bus->dev, "Reached MAX_RETRY on port read");
|
||||
dev_warn(&slave->dev, "Reached MAX_RETRY on port read");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1458,7 +1461,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
/* Read Intstat 1, Intstat 2 and Intstat 3 registers */
|
||||
ret = sdw_read_no_pm(slave, SDW_SCP_INT1);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INT1 read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1466,7 +1469,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
|
||||
ret = sdw_nread_no_pm(slave, SDW_SCP_INTSTAT2, 2, buf2);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INT2/3 read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1474,7 +1477,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
if (slave->prop.is_sdca) {
|
||||
ret = sdw_read_no_pm(slave, SDW_DP0_INT);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INT read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1571,7 +1574,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
/* Ack interrupt */
|
||||
ret = sdw_write_no_pm(slave, SDW_SCP_INT1, clear);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INT1 write failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1585,7 +1588,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
*/
|
||||
ret = sdw_read_no_pm(slave, SDW_SCP_INT1);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INT1 read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1593,7 +1596,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
|
||||
ret = sdw_nread_no_pm(slave, SDW_SCP_INTSTAT2, 2, _buf2);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_SCP_INT2/3 read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1601,7 +1604,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
if (slave->prop.is_sdca) {
|
||||
ret = sdw_read_no_pm(slave, SDW_DP0_INT);
|
||||
if (ret < 0) {
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"SDW_DP0_INT read failed:%d\n", ret);
|
||||
goto io_err;
|
||||
}
|
||||
|
@ -1627,7 +1630,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
|
|||
} while (stat != 0 && count < SDW_READ_INTR_CLEAR_RETRY);
|
||||
|
||||
if (count == SDW_READ_INTR_CLEAR_RETRY)
|
||||
dev_warn(slave->bus->dev, "Reached MAX_RETRY on alert read\n");
|
||||
dev_warn(&slave->dev, "Reached MAX_RETRY on alert read\n");
|
||||
|
||||
io_err:
|
||||
pm_runtime_mark_last_busy(&slave->dev);
|
||||
|
@ -1733,7 +1736,7 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
|
|||
case SDW_SLAVE_ALERT:
|
||||
ret = sdw_handle_slave_alerts(slave);
|
||||
if (ret)
|
||||
dev_err(bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"Slave %d alert handling failed: %d\n",
|
||||
i, ret);
|
||||
break;
|
||||
|
@ -1752,21 +1755,21 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
|
|||
|
||||
ret = sdw_initialize_slave(slave);
|
||||
if (ret)
|
||||
dev_err(bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"Slave %d initialization failed: %d\n",
|
||||
i, ret);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(bus->dev, "Invalid slave %d status:%d\n",
|
||||
dev_err(&slave->dev, "Invalid slave %d status:%d\n",
|
||||
i, status[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = sdw_update_slave_status(slave, status[i]);
|
||||
if (ret)
|
||||
dev_err(slave->bus->dev,
|
||||
dev_err(&slave->dev,
|
||||
"Update Slave status failed:%d\n", ret);
|
||||
if (attached_initializing) {
|
||||
dev_dbg(&slave->dev,
|
||||
|
|
Loading…
Reference in New Issue