diff mbox

[2/7] OMAP: PM: omap_device: add few quick access functions

Message ID 1314026347-21623-3-git-send-email-b-cousson@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benoit Cousson Aug. 22, 2011, 3:19 p.m. UTC
From: Nishanth Menon <nm@ti.com>

Provide a quick set of access functions:
a) Convert omap_device to platform_device - This is the flip of
   to_omap_device for equivalent usage
b) Convert omap_device to device pointer - This is useful for
   most devices that need to go through standard linux functions that
   take device pointer.
c) Convert hwmod to device pointer - This wrapper provides ability for
   drivers to convert directly from hwmod name back to device pointer
   without having to handle this on a driver by driver basis

Signed-off-by: Nishanth Menon <nm@ti.com>
[b-cousson@ti.com: Adapt it to the new pdev pointer inside od]
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
---
 arch/arm/plat-omap/include/plat/omap_device.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

Comments

Kevin Hilman Aug. 31, 2011, 10:23 p.m. UTC | #1
Benoit Cousson <b-cousson@ti.com> writes:

> From: Nishanth Menon <nm@ti.com>
>
> Provide a quick set of access functions:
> a) Convert omap_device to platform_device - This is the flip of
>    to_omap_device for equivalent usage
> b) Convert omap_device to device pointer - This is useful for
>    most devices that need to go through standard linux functions that
>    take device pointer.
> c) Convert hwmod to device pointer - This wrapper provides ability for
>    drivers to convert directly from hwmod name back to device pointer
>    without having to handle this on a driver by driver basis
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> [b-cousson@ti.com: Adapt it to the new pdev pointer inside od]
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> ---
>  arch/arm/plat-omap/include/plat/omap_device.h |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
> index bdc2804..903f329 100644
> --- a/arch/arm/plat-omap/include/plat/omap_device.h
> +++ b/arch/arm/plat-omap/include/plat/omap_device.h
> @@ -152,6 +152,21 @@ static inline struct omap_device *to_omap_device(struct platform_device *pdev)
>  	return pdev ? pdev->archdata.od : NULL;
>  }
>  
> +/* Convert omap_device to platform device pointer */
> +#define omap_device_get_pdev(x) ((x)->pdev)
> +/* Convert omap_device to device pointer */
> +#define omap_device_get_dev(x) (&omap_device_get_pdev(x)->dev)

I don't see these used elsewhere, and I don't think they're needed...

> +/* Convert omap_hwmod name to device pointer */
> +static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
> +{
> +	struct omap_device *od;
> +	od = omap_hwmod_name_get_odev(oh_name);
> +	if (IS_ERR_OR_NULL(od))
> +		return ERR_PTR(od ? PTR_ERR(od) : -ENODEV);
> +	return omap_device_get_dev(od);
> +}
> +

After comments on patch 1 are addressed, the 

      pdev = omap_hwmod_name_get_pdev(oh_name)
      return &pdev->dev;

Kevin

>  static inline
>  void omap_device_disable_idle_on_suspend(struct platform_device *pdev)
>  {
Benoit Cousson Sept. 1, 2011, 11:55 a.m. UTC | #2
On 9/1/2011 12:23 AM, Hilman, Kevin wrote:
> Benoit Cousson<b-cousson@ti.com>  writes:
>
>> From: Nishanth Menon<nm@ti.com>
>>
>> Provide a quick set of access functions:
>> a) Convert omap_device to platform_device - This is the flip of
>>     to_omap_device for equivalent usage
>> b) Convert omap_device to device pointer - This is useful for
>>     most devices that need to go through standard linux functions that
>>     take device pointer.
>> c) Convert hwmod to device pointer - This wrapper provides ability for
>>     drivers to convert directly from hwmod name back to device pointer
>>     without having to handle this on a driver by driver basis
>>
>> Signed-off-by: Nishanth Menon<nm@ti.com>
>> [b-cousson@ti.com: Adapt it to the new pdev pointer inside od]
>> Signed-off-by: Benoit Cousson<b-cousson@ti.com>
>> ---
>>   arch/arm/plat-omap/include/plat/omap_device.h |   15 +++++++++++++++
>>   1 files changed, 15 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
>> index bdc2804..903f329 100644
>> --- a/arch/arm/plat-omap/include/plat/omap_device.h
>> +++ b/arch/arm/plat-omap/include/plat/omap_device.h
>> @@ -152,6 +152,21 @@ static inline struct omap_device *to_omap_device(struct platform_device *pdev)
>>   	return pdev ? pdev->archdata.od : NULL;
>>   }
>>
>> +/* Convert omap_device to platform device pointer */
>> +#define omap_device_get_pdev(x) ((x)->pdev)
>> +/* Convert omap_device to device pointer */
>> +#define omap_device_get_dev(x) (&omap_device_get_pdev(x)->dev)
>
> I don't see these used elsewhere, and I don't think they're needed...

Well, there are used once... just below, and that's all.

>> +/* Convert omap_hwmod name to device pointer */
>> +static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
>> +{
>> +	struct omap_device *od;
>> +	od = omap_hwmod_name_get_odev(oh_name);
>> +	if (IS_ERR_OR_NULL(od))
>> +		return ERR_PTR(od ? PTR_ERR(od) : -ENODEV);
>> +	return omap_device_get_dev(od);
>> +}
>> +

I will let Nishant comment, but I guess the idea was that an omap_device 
API should handle omap_device pointer, and then access to pdev or dev is 
done using these helpers.

Assuming that now omap_device API should preferably use pdev, we can 
remove one step of indirection and thus get rid of the helpers, since 
they are not used anywhere else.

> After comments on patch 1 are addressed, the
>
>        pdev = omap_hwmod_name_get_pdev(oh_name)
>        return&pdev->dev;

Thanks,
Benoit
Kevin Hilman Sept. 1, 2011, 2:55 p.m. UTC | #3
"Cousson, Benoit" <b-cousson@ti.com> writes:

> On 9/1/2011 12:23 AM, Hilman, Kevin wrote:
>> Benoit Cousson<b-cousson@ti.com>  writes:
>>
>>> From: Nishanth Menon<nm@ti.com>
>>>
>>> Provide a quick set of access functions:
>>> a) Convert omap_device to platform_device - This is the flip of
>>>     to_omap_device for equivalent usage
>>> b) Convert omap_device to device pointer - This is useful for
>>>     most devices that need to go through standard linux functions that
>>>     take device pointer.
>>> c) Convert hwmod to device pointer - This wrapper provides ability for
>>>     drivers to convert directly from hwmod name back to device pointer
>>>     without having to handle this on a driver by driver basis
>>>
>>> Signed-off-by: Nishanth Menon<nm@ti.com>
>>> [b-cousson@ti.com: Adapt it to the new pdev pointer inside od]
>>> Signed-off-by: Benoit Cousson<b-cousson@ti.com>
>>> ---
>>>   arch/arm/plat-omap/include/plat/omap_device.h |   15 +++++++++++++++
>>>   1 files changed, 15 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
>>> index bdc2804..903f329 100644
>>> --- a/arch/arm/plat-omap/include/plat/omap_device.h
>>> +++ b/arch/arm/plat-omap/include/plat/omap_device.h
>>> @@ -152,6 +152,21 @@ static inline struct omap_device *to_omap_device(struct platform_device *pdev)
>>>   	return pdev ? pdev->archdata.od : NULL;
>>>   }
>>>
>>> +/* Convert omap_device to platform device pointer */
>>> +#define omap_device_get_pdev(x) ((x)->pdev)
>>> +/* Convert omap_device to device pointer */
>>> +#define omap_device_get_dev(x) (&omap_device_get_pdev(x)->dev)
>>
>> I don't see these used elsewhere, and I don't think they're needed...
>
> Well, there are used once... just below, and that's all.
>
>>> +/* Convert omap_hwmod name to device pointer */
>>> +static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
>>> +{
>>> +	struct omap_device *od;
>>> +	od = omap_hwmod_name_get_odev(oh_name);
>>> +	if (IS_ERR_OR_NULL(od))
>>> +		return ERR_PTR(od ? PTR_ERR(od) : -ENODEV);
>>> +	return omap_device_get_dev(od);
>>> +}
>>> +
>
> I will let Nishant comment, but I guess the idea was that an
> omap_device API should handle omap_device pointer, and then access to
> pdev or dev is done using these helpers.
>
> Assuming that now omap_device API should preferably use pdev, we can
> remove one step of indirection and thus get rid of the helpers, since
> they are not used anywhere else.
>

Yes please.

I've made most of the omap_device API now use pdev pointers already in
my series.

Thanks,


Kevin
Benoit Cousson Sept. 2, 2011, 12:39 p.m. UTC | #4
On 9/1/2011 12:23 AM, Hilman, Kevin wrote:
> Benoit Cousson<b-cousson@ti.com>  writes:
>
>> From: Nishanth Menon<nm@ti.com>
>>
>> Provide a quick set of access functions:
>> a) Convert omap_device to platform_device - This is the flip of
>>     to_omap_device for equivalent usage
>> b) Convert omap_device to device pointer - This is useful for
>>     most devices that need to go through standard linux functions that
>>     take device pointer.
>> c) Convert hwmod to device pointer - This wrapper provides ability for
>>     drivers to convert directly from hwmod name back to device pointer
>>     without having to handle this on a driver by driver basis
>>
>> Signed-off-by: Nishanth Menon<nm@ti.com>
>> [b-cousson@ti.com: Adapt it to the new pdev pointer inside od]
>> Signed-off-by: Benoit Cousson<b-cousson@ti.com>
>> ---
>>   arch/arm/plat-omap/include/plat/omap_device.h |   15 +++++++++++++++
>>   1 files changed, 15 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
>> index bdc2804..903f329 100644
>> --- a/arch/arm/plat-omap/include/plat/omap_device.h
>> +++ b/arch/arm/plat-omap/include/plat/omap_device.h
>> @@ -152,6 +152,21 @@ static inline struct omap_device *to_omap_device(struct platform_device *pdev)
>>   	return pdev ? pdev->archdata.od : NULL;
>>   }
>>
>> +/* Convert omap_device to platform device pointer */
>> +#define omap_device_get_pdev(x) ((x)->pdev)
>> +/* Convert omap_device to device pointer */
>> +#define omap_device_get_dev(x) (&omap_device_get_pdev(x)->dev)
>
> I don't see these used elsewhere, and I don't think they're needed...
>
>> +/* Convert omap_hwmod name to device pointer */
>> +static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
>> +{
>> +	struct omap_device *od;
>> +	od = omap_hwmod_name_get_odev(oh_name);
>> +	if (IS_ERR_OR_NULL(od))
>> +		return ERR_PTR(od ? PTR_ERR(od) : -ENODEV);
>> +	return omap_device_get_dev(od);
>> +}
>> +
>
> After comments on patch 1 are addressed, the
>
>        pdev = omap_hwmod_name_get_pdev(oh_name)
>        return&pdev->dev;

And in that case, that can be folded in the previous one I guess.

Benoit
diff mbox

Patch

diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index bdc2804..903f329 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -152,6 +152,21 @@  static inline struct omap_device *to_omap_device(struct platform_device *pdev)
 	return pdev ? pdev->archdata.od : NULL;
 }
 
+/* Convert omap_device to platform device pointer */
+#define omap_device_get_pdev(x) ((x)->pdev)
+/* Convert omap_device to device pointer */
+#define omap_device_get_dev(x) (&omap_device_get_pdev(x)->dev)
+
+/* Convert omap_hwmod name to device pointer */
+static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
+{
+	struct omap_device *od;
+	od = omap_hwmod_name_get_odev(oh_name);
+	if (IS_ERR_OR_NULL(od))
+		return ERR_PTR(od ? PTR_ERR(od) : -ENODEV);
+	return omap_device_get_dev(od);
+}
+
 static inline
 void omap_device_disable_idle_on_suspend(struct platform_device *pdev)
 {