On 2/11/2016 2:02 PM, Petr Kulhavy wrote:

This adds two functions to get DT properties "mentor,power" and "dr_mode":
musb_get_power() and musb_mode musb_get_mode()

Signed-off-by: Petr Kulhavy <p...@barix.com>
---
  drivers/usb/musb/musb_core.c | 36 ++++++++++++++++++++++++++++++++++++
  drivers/usb/musb/musb_core.h | 13 +++++++++++++
  2 files changed, 49 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index c3791a0..f96a79a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
[...]
@@ -129,6 +130,41 @@ static inline struct musb *dev_to_musb(struct device *dev)
        return dev_get_drvdata(dev);
  }

+enum musb_mode musb_get_mode(struct device *dev)
+{
+       enum usb_dr_mode mode;
+
+       mode = usb_get_dr_mode(dev);
+       switch (mode) {
+       case USB_DR_MODE_HOST:
+               return MUSB_HOST;
+
+       case USB_DR_MODE_PERIPHERAL:
+               return MUSB_PERIPHERAL;
+
+       case USB_DR_MODE_OTG:
+               return MUSB_OTG;
+
+       default:
+               return MUSB_UNDEFINED;

   I'd skip the empty lines...

+       }
+}
+EXPORT_SYMBOL_GPL(musb_get_mode);
+
+u8 musb_get_power(struct device *dev)

   Might be worth enclosing into #ifdef CONFIG_OF...

+{
+       int ret;
+       unsigned power_ma;
+
+       /* the "mentor,power" value is in milliamperes, whereas
+        * the mentor configuration is in 2mA units
+        */
+       ret = of_property_read_u32(dev->of_node, "mentor,power", &power_ma);
+
+       return ret ? 0 : power_ma / 2;

   You forgot to check for the maximum possible value (510).

+}
+EXPORT_SYMBOL_GPL(musb_get_power);
+

[...]

Actually, we also have UDC specific 'min_power' field and a number of other fields (does it really work w/o specifying 'clock' BTW?). I'd suggest a larger function, assigning directly to the platform data fields...


MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to