dm: spi: Change cs_info op to return -EINVAL for invalid cs num
We need distinguish the following two situations in various SPI APIs: - given chip select num is invalid - given chip select num is valid, but no device is attached Currently -ENODEV is returned for both cases. For the first case, it's more reasonable to return -EINVAL instead of -ENODEV for invalid chip select numbers. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Jagan Teki <jagan@amarulasolutions.com> # SoPine Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
@@ -198,7 +198,7 @@ static int ath79_cs_info(struct udevice *bus, uint cs,
|
||||
{
|
||||
/* Always allow activity on CS 0/1/2 */
|
||||
if (cs >= 3)
|
||||
return -ENODEV;
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ static int bcm63xx_hsspi_cs_info(struct udevice *bus, uint cs,
|
||||
|
||||
if (cs >= priv->num_cs) {
|
||||
printf("no cs %u\n", cs);
|
||||
return -ENODEV;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ static int bcm63xx_spi_cs_info(struct udevice *bus, uint cs,
|
||||
|
||||
if (cs >= priv->num_cs) {
|
||||
printf("no cs %u\n", cs);
|
||||
return -ENODEV;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -117,7 +117,7 @@ static int sandbox_cs_info(struct udevice *bus, uint cs,
|
||||
{
|
||||
/* Always allow activity on CS 0 */
|
||||
if (cs >= 1)
|
||||
return -ENODEV;
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ int tegra20_sflash_cs_info(struct udevice *bus, unsigned int cs,
|
||||
{
|
||||
/* Tegra20 SPI-Flash - only 1 device ('bus/cs') */
|
||||
if (cs != 0)
|
||||
return -ENODEV;
|
||||
return -EINVAL;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user