Re: [PATCH 2/2] musb: musb: dsps: determine the number of instances at runtime

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

 



Hi,

On Mon, Jun 17, 2013 at 05:13:34PM +0200, Sebastian Andrzej Siewior wrote:
> There is no need to hardcode the number of instances here. It is better to
> determine them at runtime. Even if the device provides two instances one
> might only want to use one of them.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/usb/musb/musb_dsps.c | 33 +++++++++++++++++++++++----------
>  1 file changed, 23 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index d9ff390..0ac9934 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -110,8 +110,6 @@ struct dsps_musb_wrapper {
>  	/* miscellaneous stuff */
>  	u32		musb_core_offset;
>  	u8		poll_seconds;
> -	/* number of musb instances */
> -	u8		instances;
>  };
>  
>  /**
> @@ -124,6 +122,7 @@ struct dsps_glue {
>  	struct timer_list timer[2];	/* otg_workaround timer */
>  	unsigned long last_timer[2];    /* last timer data for each instance */
>  	u32 __iomem *usb_ctrl[2];
> +	u8 instances;
>  };
>  
>  #define	DSPS_AM33XX_CONTROL_MODULE_PHYS_0	0x44e10620
> @@ -646,6 +645,23 @@ static int dsps_probe(struct platform_device *pdev)
>  	}
>  	platform_set_drvdata(pdev, glue);
>  
> +	i = 1;
> +	do {
> +		iomem = platform_get_resource(pdev, IORESOURCE_MEM, i);

IIRC this index starts at zero, no ? Meaning that this should be:

i = 0
do {
	iomem = platform_get_resource(pdev, IORESOURCE_MEM, i);
	if (!iomem)
		break;

	i++;
} while (true);

glue->instances = i + 1;

Also, why are you getting the resource and doing nothing with it ? Is it
just to figure out the amount of instances ? Isn't there a DT helper to
count how many child nodes a certain node has ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux