mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-23 22:34:21 +08:00
firmware: arm_scmi: Improve checks in the info_get operations
[ Upstream commit 1ecb7d27b1
]
SCMI protocols abstract and expose a number of protocol specific
resources like clocks, sensors and so on. Information about such
specific domain resources are generally exposed via an `info_get`
protocol operation.
Improve the sanity check on these operations where needed.
Link: https://lore.kernel.org/r/20220817172731.1185305-3-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
64b79e6328
commit
9f81dbb934
@ -315,9 +315,13 @@ static int scmi_clock_count_get(const struct scmi_protocol_handle *ph)
|
||||
static const struct scmi_clock_info *
|
||||
scmi_clock_info_get(const struct scmi_protocol_handle *ph, u32 clk_id)
|
||||
{
|
||||
struct scmi_clock_info *clk;
|
||||
struct clock_info *ci = ph->get_priv(ph);
|
||||
struct scmi_clock_info *clk = ci->clk + clk_id;
|
||||
|
||||
if (clk_id >= ci->num_clocks)
|
||||
return NULL;
|
||||
|
||||
clk = ci->clk + clk_id;
|
||||
if (!clk->name[0])
|
||||
return NULL;
|
||||
|
||||
|
@ -817,6 +817,9 @@ scmi_sensor_info_get(const struct scmi_protocol_handle *ph, u32 sensor_id)
|
||||
{
|
||||
struct sensors_info *si = ph->get_priv(ph);
|
||||
|
||||
if (sensor_id >= si->num_sensors)
|
||||
return NULL;
|
||||
|
||||
return si->sensors + sensor_id;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ struct scmi_protocol_handle;
|
||||
struct scmi_clk_proto_ops {
|
||||
int (*count_get)(const struct scmi_protocol_handle *ph);
|
||||
|
||||
const struct scmi_clock_info *(*info_get)
|
||||
const struct scmi_clock_info __must_check *(*info_get)
|
||||
(const struct scmi_protocol_handle *ph, u32 clk_id);
|
||||
int (*rate_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
|
||||
u64 *rate);
|
||||
@ -452,7 +452,7 @@ enum scmi_sensor_class {
|
||||
*/
|
||||
struct scmi_sensor_proto_ops {
|
||||
int (*count_get)(const struct scmi_protocol_handle *ph);
|
||||
const struct scmi_sensor_info *(*info_get)
|
||||
const struct scmi_sensor_info __must_check *(*info_get)
|
||||
(const struct scmi_protocol_handle *ph, u32 sensor_id);
|
||||
int (*trip_point_config)(const struct scmi_protocol_handle *ph,
|
||||
u32 sensor_id, u8 trip_id, u64 trip_value);
|
||||
|
Loading…
Reference in New Issue
Block a user