[PATCH linux dev-5.2 v2 2/4] i2c: Aspeed: Avoid invalid resource warning for byte mode

Eddie James eajames at linux.ibm.com
Sat Sep 14 02:15:51 AEST 2019


If the Aspeed I2C busses don't have the buffer memory specified in the
devicetree, the probe function will throw a warning for non-AST2500
SOCs. This is unnecessary and confusing since operating in byte mode
is perfectly valid. Avoid this by checking the resource pointer before
attempting to map it.

Signed-off-by: Eddie James <eajames at linux.ibm.com>
---
 drivers/i2c/busses/i2c-aspeed.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 1943977..464c86a 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -1393,17 +1393,19 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
 		struct resource *res = platform_get_resource(pdev,
 							     IORESOURCE_MEM, 1);
 
-		bus->buf_base = devm_ioremap_resource(&pdev->dev, res);
-		if (IS_ERR(bus->buf_base) || resource_size(res) < 2) {
-			bus->buf_base = NULL;
-		} else {
-			bus->buf_size = resource_size(res);
-			if (of_device_is_compatible(pdev->dev.of_node,
-						    "aspeed,ast2400-i2c-bus")) {
-				bus->buf_page = ((res->start >> 8) &
-						 GENMASK(3, 0)) - 8;
-				bus->buf_offset = (res->start >> 2) &
-						  ASPEED_I2CD_BUF_OFFSET_MASK;
+		if (res) {
+			bus->buf_base = devm_ioremap_resource(&pdev->dev, res);
+			if (IS_ERR(bus->buf_base) || resource_size(res) < 2) {
+				bus->buf_base = NULL;
+			} else {
+				bus->buf_size = resource_size(res);
+				if (of_device_is_compatible(pdev->dev.of_node,
+							    "aspeed,ast2400-i2c-bus")) {
+					bus->buf_page = ((res->start >> 8) &
+						GENMASK(3, 0)) - 8;
+					bus->buf_offset = (res->start >> 2) &
+						ASPEED_I2CD_BUF_OFFSET_MASK;
+				}
 			}
 		}
 	}
-- 
1.8.3.1



More information about the openbmc mailing list