From nobody Mon Feb 9 01:35:07 2026 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD58014A4F0 for ; Thu, 15 Jan 2026 00:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768437331; cv=none; b=rbtJKKRHgSUN+3lsQv0KsBcvGllzlgtlqWuiT4+oa204wBnZ/lPxjB+cg4STV6k9ituu6CnwBTzY6DEqhgeXQCDQm8KPlkIT9rtx2Obpc/+5XHPX4Y+IfrsWdmSvRMEzBVqeF6K664xLuSQnsD7oCMTi/qIGGcdaTF2mCXBNL/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768437331; c=relaxed/simple; bh=D+o9vPZSG/d10yirYMKAstqJxZqhz1gw+/PomftMNAg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZhYCe1e/x8Fwmxquo28u23cCttoZ0qckROEaKLr6GzEfOKd9wdfWnKucn8AW8v6Hh32a13yAseoQvW4vnS9NH68AmNDP74GsRG5pHx6Ok+84y2DXJY+hnvluPWDo4AgendQ2wehkWxL741d6P4ddRlgxHH0O0kcgejYjPLfsNDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=FCmE2Pnv; arc=none smtp.client-ip=74.125.82.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="FCmE2Pnv" Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-12331482b8fso1138320c88.1 for ; Wed, 14 Jan 2026 16:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1768437329; x=1769042129; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=10mA/zkrWdYHsfLbKNdwoYiN3H67w2t23OWy9hIoOK4=; b=FCmE2PnvOxJ6QCofsPSa6UCfwhcn4l4u8xMdiVxjhB0//RXWaPtEJvTwnHaBHXoquH ZargPB++MXQ8D3IJ3iZPBy9y5F/o06xBmG+ITr7uZMyUvAqxd/3U3S3o35PYibMC07mL CjS/B8hdW7eJ9rWHId1WBL2uKph3VdxT+YHhp8YWV2QTDBNPhNMlF1uU98NQmL9Dit1F KeF9GzDgweEfxH6jApqmRGYjQ4zn4XwRXt6kFTQZQ4R2plD6V/kiZCPcCIbizoIChaaO TYdMdDgMEZBQ+KLuU79EyD4xLjcmlWLCAFfJ3oUTO3xI4qeLbwDA99lviPBEW6e8QYaC fJdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768437329; x=1769042129; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=10mA/zkrWdYHsfLbKNdwoYiN3H67w2t23OWy9hIoOK4=; b=lsxT4z7uV0TwolEQZZLBGP5as7XuGPQgcR0Geb6j9u3df/cWTZ0bBllwBNsyxru+Ir NmDHV6fP5NcZORyaqAuyRubSx2Yh9EZry4808eEBF63m9xUYnTK0PLh4ZIKUw03lw1Rl dyS71eULpS2B/c9K4Hu4vi8LQ5c5qOfFrsCXhb3aFNjlinIAsDNwsNIaC2XAth/RPzzp wWoINAFJApGypkw7/H8TdCgti5IAupqr5l2cD0dqfhrL0Rg659fcTdZilJOsUrGmqITR DgjEY/MSTsqNVjcEVcqa8yfy6lofogTrbRaHqe+npdQYwJx0sdD1yU1qvcK/9Z364Qkj oWnA== X-Forwarded-Encrypted: i=1; AJvYcCWD3G1EyACpBsrjS0RXeCo99mmAuSxSSIcmNlGbOnieLDhABoOnTSyKemLSimMLvzt/TJeYWxSYGtLg7qg=@vger.kernel.org X-Gm-Message-State: AOJu0YzdsVFTAJU1/tCXBz7Cs+4n5pB5DBvHOFGacD4emcOe6Kw+Rhox HM8kJCI5d3uJNvrk8p6qUy/TECmb8ce0fZV+K6EfC+vGzB4Q6gS9DzXH/e7QnRbSbAk= X-Gm-Gg: AY/fxX7UPwE3/bdvRcAUYETFHyV2CywI9QCsNvO1XXjP10sr4Vw5FcjBf0ESovRJH8N /zE4nhKp+OapfkcsuTij+V+B1Fiq5kcjEmrDCXHQsDdT3GOrRAJHnD12E4yABlSxFlbI4NZruZA z8k2BREbxr5GUNKrFlq70m7y3i154QDopENVE6TjFbcRwusQGc3LAsm4onlWhY8nK8xFLGYOPYG fgAmQG5JwEiPOstq+RCR4in4XJCDjUxfnNtYjMLFVRzJaTchlUyYn4W9pPUt0dHXDPGOHzGJ8Ss 5UX6cpWNWBtAdg9B1WhPNuSjWuVqafGMI3bMc7x2QiLW2HKqdf6VIIFOU1ldFRhcOlD+w+iUF3/ MefMxxkLVx5vqJLoIxcFwXcMCA2o50mSdMPYoG8A+xb+Es34C8VOalHwRt3sUMGmcF3wkmS9Znx A/gRKp2LvDRRg= X-Received: by 2002:a05:7022:109a:b0:119:e56b:957c with SMTP id a92af1059eb24-123376ca859mr3733235c88.1.1768437328759; Wed, 14 Jan 2026 16:35:28 -0800 (PST) Received: from localhost ([50.145.100.178]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121f24346b5sm33527379c88.3.2026.01.14.16.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 16:35:28 -0800 (PST) From: Abdurrahman Hussain To: Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain Subject: [PATCH] i2c: mux: reg: use device property accessors Date: Thu, 15 Jan 2026 00:35:23 +0000 Message-ID: <20260115003523.26660-1-abdurrahman@nexthop.ai> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This makes the driver work on non-OF platforms. Signed-off-by: Abdurrahman Hussain --- drivers/i2c/muxes/i2c-mux-reg.c | 96 ++++++++++++--------------------- 1 file changed, 33 insertions(+), 63 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-re= g.c index 1e566ea92bc9..48d7b3f740ad 100644 --- a/drivers/i2c/muxes/i2c-mux-reg.c +++ b/drivers/i2c/muxes/i2c-mux-reg.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -75,83 +74,59 @@ static int i2c_mux_reg_deselect(struct i2c_mux_core *mu= xc, u32 chan) return 0; } =20 -#ifdef CONFIG_OF -static int i2c_mux_reg_probe_dt(struct regmux *mux, - struct platform_device *pdev) +static int i2c_mux_reg_probe_fw(struct regmux *mux, struct device *dev) { - struct device_node *np =3D pdev->dev.of_node; - struct device_node *adapter_np, *child; + struct fwnode_handle *fwnode, *child; struct i2c_adapter *adapter; - struct resource res; unsigned *values; - int i =3D 0; + int ret, i =3D 0; =20 - if (!np) + if (!dev_fwnode(dev)) return -ENODEV; =20 - adapter_np =3D of_parse_phandle(np, "i2c-parent", 0); - if (!adapter_np) { - dev_err(&pdev->dev, "Cannot parse i2c-parent\n"); + fwnode =3D fwnode_find_reference(dev_fwnode(dev), "i2c-parent", 0); + if (IS_ERR(fwnode)) { + dev_err(dev, "missing 'i2c-parent' property\n"); return -ENODEV; } - adapter =3D of_find_i2c_adapter_by_node(adapter_np); - of_node_put(adapter_np); + + adapter =3D i2c_get_adapter_by_fwnode(fwnode); + fwnode_handle_put(fwnode); if (!adapter) return -EPROBE_DEFER; =20 mux->data.parent =3D i2c_adapter_id(adapter); put_device(&adapter->dev); =20 - mux->data.n_values =3D of_get_child_count(np); - if (of_property_read_bool(np, "little-endian")) { - mux->data.little_endian =3D true; - } else if (of_property_read_bool(np, "big-endian")) { - mux->data.little_endian =3D false; - } else { -#if defined(__BYTE_ORDER) ? __BYTE_ORDER =3D=3D __LITTLE_ENDIAN : \ - defined(__LITTLE_ENDIAN) - mux->data.little_endian =3D true; -#elif defined(__BYTE_ORDER) ? __BYTE_ORDER =3D=3D __BIG_ENDIAN : \ - defined(__BIG_ENDIAN) - mux->data.little_endian =3D false; -#else -#error Endianness not defined? -#endif - } - mux->data.write_only =3D of_property_read_bool(np, "write-only"); + mux->data.n_values =3D device_get_child_node_count(dev); + mux->data.little_endian =3D !device_is_big_endian(dev); + mux->data.write_only =3D device_property_read_bool(dev, "write-only"); =20 - values =3D devm_kcalloc(&pdev->dev, - mux->data.n_values, sizeof(*mux->data.values), + values =3D devm_kcalloc(dev, mux->data.n_values, sizeof(*mux->data.values= ), GFP_KERNEL); if (!values) return -ENOMEM; =20 - for_each_child_of_node(np, child) { - of_property_read_u32(child, "reg", values + i); + device_for_each_child_node(dev, child) { + if (is_of_node(child)) { + fwnode_property_read_u32(child, "reg", values + i); + } else if (is_acpi_node(child)) { + ret =3D acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i); + if (ret) { + fwnode_handle_put(child); + return dev_err_probe(dev, ret, "Cannot get address\n"); + } + } + i++; } mux->data.values =3D values; =20 - if (!of_property_read_u32(np, "idle-state", &mux->data.idle)) + if (!device_property_read_u32(dev, "idle-state", &mux->data.idle)) mux->data.idle_in_use =3D true; =20 - /* map address from "reg" if exists */ - if (of_address_to_resource(np, 0, &res) =3D=3D 0) { - mux->data.reg_size =3D resource_size(&res); - mux->data.reg =3D devm_ioremap_resource(&pdev->dev, &res); - if (IS_ERR(mux->data.reg)) - return PTR_ERR(mux->data.reg); - } - - return 0; -} -#else -static int i2c_mux_reg_probe_dt(struct regmux *mux, - struct platform_device *pdev) -{ return 0; } -#endif =20 static int i2c_mux_reg_probe(struct platform_device *pdev) { @@ -169,26 +144,21 @@ static int i2c_mux_reg_probe(struct platform_device *= pdev) memcpy(&mux->data, dev_get_platdata(&pdev->dev), sizeof(mux->data)); } else { - ret =3D i2c_mux_reg_probe_dt(mux, pdev); + ret =3D i2c_mux_reg_probe_fw(mux, &pdev->dev); if (ret < 0) - return dev_err_probe(&pdev->dev, ret, - "Error parsing device tree"); + return ret; } =20 parent =3D i2c_get_adapter(mux->data.parent); if (!parent) return -EPROBE_DEFER; =20 - if (!mux->data.reg) { - dev_info(&pdev->dev, - "Register not set, using platform resource\n"); - mux->data.reg =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(mux->data.reg)) { - ret =3D PTR_ERR(mux->data.reg); - goto err_put_parent; - } - mux->data.reg_size =3D resource_size(res); + mux->data.reg =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(mux->data.reg)) { + ret =3D PTR_ERR(mux->data.reg); + goto err_put_parent; } + mux->data.reg_size =3D resource_size(res); =20 if (mux->data.reg_size !=3D 4 && mux->data.reg_size !=3D 2 && mux->data.reg_size !=3D 1) { --=20 2.52.0