diff mbox series

[RFC,36/57] drivers: mei: Use class_find_device_by_devt match helper

Message ID 1559577023-558-37-git-send-email-suzuki.poulose@arm.com
State New
Headers show
Series [RFC,01/57] drivers: s390/cio: Use driver_for_each_device | expand

Commit Message

Suzuki K Poulose June 3, 2019, 3:50 p.m. UTC
Switch to the generic helper class_find_device_by_devt.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

---
 drivers/misc/mei/main.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

-- 
2.7.4

Comments

Winkler, Tomas June 3, 2019, 6 p.m. UTC | #1
> -----Original Message-----

> From: Suzuki K Poulose [mailto:suzuki.poulose@arm.com]

> Sent: Monday, June 03, 2019 18:50

> To: linux-kernel@vger.kernel.org

> Cc: gregkh@linuxfoundation.org; rafael@kernel.org; suzuki.poulose@arm.com;

> Winkler, Tomas <tomas.winkler@intel.com>; Arnd Bergmann

> <arnd@arndb.de>

> Subject: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match

> helper

> 

> Switch to the generic helper class_find_device_by_devt.


Looks okay, but  you could add me at least to cover later mail, there is very little context. 


Thanks
Tomas


> 

> Cc: Tomas Winkler <tomas.winkler@intel.com>

> Cc: Arnd Bergmann <arnd@arndb.de>

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

> ---

>  drivers/misc/mei/main.c | 9 +--------

>  1 file changed, 1 insertion(+), 8 deletions(-)

> 

> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index

> ad02097..243b481 100644

> --- a/drivers/misc/mei/main.c

> +++ b/drivers/misc/mei/main.c

> @@ -858,13 +858,6 @@ static ssize_t dev_state_show(struct device *device,  }

> static DEVICE_ATTR_RO(dev_state);

> 

> -static int match_devt(struct device *dev, const void *data) -{

> -	const dev_t *devt = data;

> -

> -	return dev->devt == *devt;

> -}

> -

>  /**

>   * dev_set_devstate: set to new device state and notify sysfs file.

>   *

> @@ -880,7 +873,7 @@ void mei_set_devstate(struct mei_device *dev, enum

> mei_dev_state state)

> 

>  	dev->dev_state = state;

> 

> -	clsdev = class_find_device(mei_class, NULL, &dev->cdev.dev,

> match_devt);

> +	clsdev = class_find_device_by_devt(mei_class, NULL, dev->cdev.dev);

>  	if (clsdev) {

>  		sysfs_notify(&clsdev->kobj, NULL, "dev_state");

>  		put_device(clsdev);

> --

> 2.7.4
Suzuki K Poulose June 4, 2019, 8:27 a.m. UTC | #2
Hi Tomas,

On 03/06/2019 19:00, Winkler, Tomas wrote:
> 

> 

>> -----Original Message-----

>> From: Suzuki K Poulose [mailto:suzuki.poulose@arm.com]

>> Sent: Monday, June 03, 2019 18:50

>> To: linux-kernel@vger.kernel.org

>> Cc: gregkh@linuxfoundation.org; rafael@kernel.org; suzuki.poulose@arm.com;

>> Winkler, Tomas <tomas.winkler@intel.com>; Arnd Bergmann

>> <arnd@arndb.de>

>> Subject: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match

>> helper

>>

>> Switch to the generic helper class_find_device_by_devt.

> 

> Looks okay, but  you could add me at least to cover later mail, there is very little context.


You were on the Cc list. I am not sure if the cover-letter was kind of blocked
due to the large Cc set. Please find it below. I can see that you are copied
on the cover letter in my inbox. The subject of is :

"[RFC PATCH 00/57] drivers: Consolidate device lookup helpers"

--- cover ---

We have helper routines to lookup devices matching a criteria defined
by a "match" helper for bus/class/driver. Often the search is based on a
generic property of a device, such as of_node, fwnode, device type or
device name. In the absense of a common set of match functions, we have
drivers writing their own match functions, spilled all over the driver
subsystems. This series is an attempt to consolidate the and cleanup
the device match functions by providing generic match helpers by device
properties listed above. In this attempt, we unify the prototype for
the match functions for {bus/driver}_find_device() with that of the
class_find_device() and thus further reducing the duplicate functions.
The series also adds wrapper functions to lookup the devices by generic
attributes, so that people don't miss the generic match functions and
continue to write their own.

Also, there are a couple of instances where the drivers use "platform_bus_type"
directly reusing the "match" function of the bus. This is cleaned by providing
a new helper "platform_find_device_by_driver()" to abstract the details away
from the callers.

Applies on 5.2-rc3

Cc: Alan Tull <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
...
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
*Cc: Tomas Winkler <tomas.winkler@intel.com>*
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
...

----

Cheers
Suzuki

> 

> 

> Thanks

> Tomas

> 

> 

>>

>> Cc: Tomas Winkler <tomas.winkler@intel.com>

>> Cc: Arnd Bergmann <arnd@arndb.de>

>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

>> ---

>>   drivers/misc/mei/main.c | 9 +--------

>>   1 file changed, 1 insertion(+), 8 deletions(-)

>>

>> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index

>> ad02097..243b481 100644

>> --- a/drivers/misc/mei/main.c

>> +++ b/drivers/misc/mei/main.c

>> @@ -858,13 +858,6 @@ static ssize_t dev_state_show(struct device *device,  }

>> static DEVICE_ATTR_RO(dev_state);

>>

>> -static int match_devt(struct device *dev, const void *data) -{

>> -	const dev_t *devt = data;

>> -

>> -	return dev->devt == *devt;

>> -}

>> -

>>   /**

>>    * dev_set_devstate: set to new device state and notify sysfs file.

>>    *

>> @@ -880,7 +873,7 @@ void mei_set_devstate(struct mei_device *dev, enum

>> mei_dev_state state)

>>

>>   	dev->dev_state = state;

>>

>> -	clsdev = class_find_device(mei_class, NULL, &dev->cdev.dev,

>> match_devt);

>> +	clsdev = class_find_device_by_devt(mei_class, NULL, dev->cdev.dev);

>>   	if (clsdev) {

>>   		sysfs_notify(&clsdev->kobj, NULL, "dev_state");

>>   		put_device(clsdev);

>> --

>> 2.7.4

>
diff mbox series

Patch

diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index ad02097..243b481 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -858,13 +858,6 @@  static ssize_t dev_state_show(struct device *device,
 }
 static DEVICE_ATTR_RO(dev_state);
 
-static int match_devt(struct device *dev, const void *data)
-{
-	const dev_t *devt = data;
-
-	return dev->devt == *devt;
-}
-
 /**
  * dev_set_devstate: set to new device state and notify sysfs file.
  *
@@ -880,7 +873,7 @@  void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state)
 
 	dev->dev_state = state;
 
-	clsdev = class_find_device(mei_class, NULL, &dev->cdev.dev, match_devt);
+	clsdev = class_find_device_by_devt(mei_class, NULL, dev->cdev.dev);
 	if (clsdev) {
 		sysfs_notify(&clsdev->kobj, NULL, "dev_state");
 		put_device(clsdev);