HID: intel-ish-hid: Add match callback to ishtp bus type
Currently we depend on the guid check in ishtp_cl_driver.probe to match the device and driver. However Linux device core first calls the match() callback to decide the matching of driver and device, and then does some preparation before calling the driver probe function. If we return error in the driver probe, it needs to tear down all the preparation work and retry with next driver. Adding the match callback can avoid the unnecessary entry into unmatched driver probe function for ishtp clients reported by FW. Signed-off-by: Hong Liu <hong.liu@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
Родитель
e19595fcab
Коммит
6b3f75f75f
|
@ -803,10 +803,6 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
|
|||
if (!cl_device)
|
||||
return -ENODEV;
|
||||
|
||||
if (!guid_equal(&hid_ishtp_guid,
|
||||
&cl_device->fw_client->props.protocol_name))
|
||||
return -ENODEV;
|
||||
|
||||
client_data = devm_kzalloc(&cl_device->dev, sizeof(*client_data),
|
||||
GFP_KERNEL);
|
||||
if (!client_data)
|
||||
|
@ -937,6 +933,7 @@ static const struct dev_pm_ops hid_ishtp_pm_ops = {
|
|||
|
||||
static struct ishtp_cl_driver hid_ishtp_cl_driver = {
|
||||
.name = "ish-hid",
|
||||
.guid = &hid_ishtp_guid,
|
||||
.probe = hid_ishtp_cl_probe,
|
||||
.remove = hid_ishtp_cl_remove,
|
||||
.reset = hid_ishtp_cl_reset,
|
||||
|
|
|
@ -219,6 +219,26 @@ static int ishtp_cl_device_probe(struct device *dev)
|
|||
return driver->probe(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* ishtp_cl_bus_match() - Bus match() callback
|
||||
* @dev: the device structure
|
||||
* @drv: the driver structure
|
||||
*
|
||||
* This is a bus match callback, called when a new ishtp_cl_device is
|
||||
* registered during ishtp bus client enumeration. Use the guid_t in
|
||||
* drv and dev to decide whether they match or not.
|
||||
*
|
||||
* Return: 1 if dev & drv matches, 0 otherwise.
|
||||
*/
|
||||
static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
|
||||
struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
|
||||
|
||||
return guid_equal(driver->guid,
|
||||
&device->fw_client->props.protocol_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* ishtp_cl_device_remove() - Bus remove() callback
|
||||
* @dev: the device structure
|
||||
|
@ -372,6 +392,7 @@ static struct bus_type ishtp_cl_bus_type = {
|
|||
.name = "ishtp",
|
||||
.dev_groups = ishtp_cl_dev_groups,
|
||||
.probe = ishtp_cl_device_probe,
|
||||
.match = ishtp_cl_bus_match,
|
||||
.remove = ishtp_cl_device_remove,
|
||||
.pm = &ishtp_cl_bus_dev_pm_ops,
|
||||
.uevent = ishtp_cl_uevent,
|
||||
|
|
|
@ -64,6 +64,7 @@ struct ishtp_cl_device {
|
|||
struct ishtp_cl_driver {
|
||||
struct device_driver driver;
|
||||
const char *name;
|
||||
const guid_t *guid;
|
||||
int (*probe)(struct ishtp_cl_device *dev);
|
||||
int (*remove)(struct ishtp_cl_device *dev);
|
||||
int (*reset)(struct ishtp_cl_device *dev);
|
||||
|
|
Загрузка…
Ссылка в новой задаче