mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-15 18:34:47 +08:00
firmware: arm_scmi: Move handle get/set helpers
Move handle get/set helpers definitions into driver.c and invoke them through the bus notifier helper. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Link: https://lore.kernel.org/r/20221222185049.737625-7-cristian.marussi@arm.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
d3cd7c525f
commit
971fc0665f
@ -344,27 +344,10 @@ put_dev:
|
||||
void scmi_device_destroy(struct scmi_device *scmi_dev)
|
||||
{
|
||||
kfree_const(scmi_dev->name);
|
||||
scmi_handle_put(scmi_dev->handle);
|
||||
ida_free(&scmi_bus_id, scmi_dev->id);
|
||||
device_unregister(&scmi_dev->dev);
|
||||
}
|
||||
|
||||
void scmi_device_link_add(struct device *consumer, struct device *supplier)
|
||||
{
|
||||
struct device_link *link;
|
||||
|
||||
link = device_link_add(consumer, supplier, DL_FLAG_AUTOREMOVE_CONSUMER);
|
||||
|
||||
WARN_ON(!link);
|
||||
}
|
||||
|
||||
void scmi_set_handle(struct scmi_device *scmi_dev)
|
||||
{
|
||||
scmi_dev->handle = scmi_handle_get(&scmi_dev->dev);
|
||||
if (scmi_dev->handle)
|
||||
scmi_device_link_add(&scmi_dev->dev, scmi_dev->handle->dev);
|
||||
}
|
||||
|
||||
static int __scmi_devices_unregister(struct device *dev, void *data)
|
||||
{
|
||||
struct scmi_device *scmi_dev = to_scmi_dev(dev);
|
||||
|
@ -96,10 +96,6 @@ static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
|
||||
|
||||
struct scmi_revision_info *
|
||||
scmi_revision_area_get(const struct scmi_protocol_handle *ph);
|
||||
int scmi_handle_put(const struct scmi_handle *handle);
|
||||
void scmi_device_link_add(struct device *consumer, struct device *supplier);
|
||||
struct scmi_handle *scmi_handle_get(struct device *dev);
|
||||
void scmi_set_handle(struct scmi_device *scmi_dev);
|
||||
void scmi_setup_protocol_implemented(const struct scmi_protocol_handle *ph,
|
||||
u8 *prot_imp);
|
||||
|
||||
|
@ -1890,13 +1890,6 @@ static bool scmi_is_transport_atomic(const struct scmi_handle *handle,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct scmi_handle *scmi_handle_get_from_info_unlocked(struct scmi_info *info)
|
||||
{
|
||||
info->users++;
|
||||
return &info->handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* scmi_handle_get() - Get the SCMI handle for a device
|
||||
*
|
||||
@ -1908,7 +1901,7 @@ struct scmi_handle *scmi_handle_get_from_info_unlocked(struct scmi_info *info)
|
||||
*
|
||||
* Return: pointer to handle if successful, NULL on error
|
||||
*/
|
||||
struct scmi_handle *scmi_handle_get(struct device *dev)
|
||||
static struct scmi_handle *scmi_handle_get(struct device *dev)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct scmi_info *info;
|
||||
@ -1918,7 +1911,8 @@ struct scmi_handle *scmi_handle_get(struct device *dev)
|
||||
list_for_each(p, &scmi_list) {
|
||||
info = list_entry(p, struct scmi_info, node);
|
||||
if (dev->parent == info->dev) {
|
||||
handle = scmi_handle_get_from_info_unlocked(info);
|
||||
info->users++;
|
||||
handle = &info->handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1939,7 +1933,7 @@ struct scmi_handle *scmi_handle_get(struct device *dev)
|
||||
* Return: 0 is successfully released
|
||||
* if null was passed, it returns -EINVAL;
|
||||
*/
|
||||
int scmi_handle_put(const struct scmi_handle *handle)
|
||||
static int scmi_handle_put(const struct scmi_handle *handle)
|
||||
{
|
||||
struct scmi_info *info;
|
||||
|
||||
@ -1955,6 +1949,23 @@ int scmi_handle_put(const struct scmi_handle *handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scmi_device_link_add(struct device *consumer,
|
||||
struct device *supplier)
|
||||
{
|
||||
struct device_link *link;
|
||||
|
||||
link = device_link_add(consumer, supplier, DL_FLAG_AUTOREMOVE_CONSUMER);
|
||||
|
||||
WARN_ON(!link);
|
||||
}
|
||||
|
||||
static void scmi_set_handle(struct scmi_device *scmi_dev)
|
||||
{
|
||||
scmi_dev->handle = scmi_handle_get(&scmi_dev->dev);
|
||||
if (scmi_dev->handle)
|
||||
scmi_device_link_add(&scmi_dev->dev, scmi_dev->handle->dev);
|
||||
}
|
||||
|
||||
static int __scmi_xfer_info_init(struct scmi_info *sinfo,
|
||||
struct scmi_xfers_info *info)
|
||||
{
|
||||
@ -2234,8 +2245,12 @@ static int scmi_bus_notifier(struct notifier_block *nb,
|
||||
|
||||
switch (action) {
|
||||
case BUS_NOTIFY_BIND_DRIVER:
|
||||
/* setup handle now as the transport is ready */
|
||||
scmi_set_handle(sdev);
|
||||
break;
|
||||
case BUS_NOTIFY_UNBOUND_DRIVER:
|
||||
scmi_handle_put(sdev->handle);
|
||||
sdev->handle = NULL;
|
||||
break;
|
||||
default:
|
||||
return NOTIFY_DONE;
|
||||
|
Loading…
Reference in New Issue
Block a user