Re: [Patch v2 02/14] usb: phy-mxs: Add platform judgement code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 23, 2013 at 05:04:44PM +0800, Shawn Guo wrote:
> On Wed, Oct 23, 2013 at 02:46:04PM +0800, Peter Chen wrote:
> > How about compare compatible string directly at probe?
> > 
> > 	if (of_device_is_compatible(np, "fsl,imx6q-usbphy"))
> > 		mxs_phy->devtype = IMX6Q_USB_PHY;
> > 	else if ((of_device_is_compatible(np, "fsl,imx6sl-usbphy"))
> > 		mxs_phy->devtype = IMX6SL_USB_PHY;
> > 	else if (...)
> > 		...;
> 
> It can work, but in general, we should avoid unnecessary device tree
> lookup.  I would suggest something like below.
> 
> #define MXS_FLAGS_SUSPEND_ISSUE_1	BIT(0)
> #define MXS_FLAGS_SUSPEND_ISSUE_2	BIT(1)
> #define MXS_FLAGS_LINE_DISCONNECT	BIT(2)
> 
> struct mxs_phy_data {
> 	unsigned int flags;
> };
> 
> struct mxs_phy {
> 	...
> 	mxs_phy_data *data;
> };
> 
> static struct mxs_phy_data imx6sl_usbphy_data = {
>         .flags = MXS_FLAGS_LINE_DISCONNECT,
> };
> 
> static struct mxs_phy_data imx6q_usbphy_data = {
>         .flags = MXS_FLAGS_SUSPEND_ISSUE_2 | MXS_FLAGS_LINE_DISCONNECT,
> };
> 
> static struct mxs_phy_data imx23_usbphy_data = {
>         .flags = MXS_FLAGS_SUSPEND_ISSUE_1 | MXS_FLAGS_SUSPEND_ISSUE_2,
> };
> 
> static const struct of_device_id mxs_phy_dt_ids[] = {
>        { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_usbphy_data, },
>        { .compatible = "fsl,imx6q-usbphy", .data = &imx6q_usbphy_data, },
>        { .compatible = "fsl,imx23-usbphy", .data = &imx23_usbphy_data, },
>        { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
> 
> Then you can check the flags for handling different cases.  This would
> be more flexible and future proof.
> 

Great, I will use that way at chipidea driver too.

-- 

Best Regards,
Peter Chen

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux