diff mbox series

[2/2] i2c: fsi: Prevent adding adapters for ports without dts nodes

Message ID 20200608160544.7134-3-eajames@linux.ibm.com
State Superseded
Headers show
Series i2c: fsi: Fixes for systems with more ports | expand

Commit Message

Eddie James June 8, 2020, 4:05 p.m. UTC
Ports should be defined in the devicetree if they are to be enabled on
the system.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/i2c/busses/i2c-fsi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko June 8, 2020, 4:31 p.m. UTC | #1
On Mon, Jun 8, 2020 at 7:05 PM Eddie James <eajames@linux.ibm.com> wrote:
>
> Ports should be defined in the devicetree if they are to be enabled on
> the system.

...

>         for (port_no = 0; port_no < ports; port_no++) {
>                 np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
> -               if (np && !of_device_is_available(np))

> +               /* Do not add port if it is not described in the device tree */
> +               if (!np)
> +                       continue;

I believe this is redundant, since below will do the same second time.

> +               /* Do not add port if it is described as disabled */
> +               if (!of_device_is_available(np))
>                         continue;
Eddie James June 8, 2020, 6:12 p.m. UTC | #2
On 6/8/20 11:31 AM, Andy Shevchenko wrote:
> On Mon, Jun 8, 2020 at 7:05 PM Eddie James <eajames@linux.ibm.com> wrote:
>> Ports should be defined in the devicetree if they are to be enabled on
>> the system.
> ...
>
>>          for (port_no = 0; port_no < ports; port_no++) {
>>                  np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
>> -               if (np && !of_device_is_available(np))
>> +               /* Do not add port if it is not described in the device tree */
>> +               if (!np)
>> +                       continue;
> I believe this is redundant, since below will do the same second time.


Good point, thanks, I'll update that.


>
>> +               /* Do not add port if it is described as disabled */
>> +               if (!of_device_is_available(np))
>>                          continue;
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index 977d6f524649..95b6b6bc1d78 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -703,7 +703,12 @@  static int fsi_i2c_probe(struct device *dev)
 
 	for (port_no = 0; port_no < ports; port_no++) {
 		np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
-		if (np && !of_device_is_available(np))
+		/* Do not add port if it is not described in the device tree */
+		if (!np)
+			continue;
+
+		/* Do not add port if it is described as disabled */
+		if (!of_device_is_available(np))
 			continue;
 
 		port = kzalloc(sizeof(*port), GFP_KERNEL);