From nobody Mon Apr 6 18:24:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39B743D8917; Wed, 18 Mar 2026 13:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773841443; cv=none; b=h7qh4PhQx2i1LCGViu8JcbuqCKvMhzyfJMBel7rCLoAmWAbPQeSEBWN2kvKHp/tudB4UKrlA4rRrKfd78w0iwwGo9Q4fw5/NoquwKIjCDesSsTyb1Cr66Mxqn4n4eh1WoLDkarUD7K6Pff8jbPKgVyOWSNDMz9T2qa/jwGCYoSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773841443; c=relaxed/simple; bh=trAQf7hV5ZPnfdrp8wqAugv9ikSXYxyDoELp///NIuo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=YeneeD+lyyEmiW9/P3giVDvWmvKly7J1129JtLOKxCUFg5NUrQdWCEnemoDMGjCau1zQtEJTHkPbiCITSS59/RGh0nDuX4kvz1UqQp3soZqfgBRBKxIOyggcdloeKrQ9m4umTZ7x7Q5GVdeAOT6Agvm6mtqTl1UK1D25G33tnfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ieHyQs7G; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ieHyQs7G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7098EC2BC87; Wed, 18 Mar 2026 13:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773841442; bh=trAQf7hV5ZPnfdrp8wqAugv9ikSXYxyDoELp///NIuo=; h=From:To:Cc:Subject:Date:From; b=ieHyQs7Gq2+ijMerPe1beSREqAGDUgv8P6J71kjErAkx7Bcd+tB6DAkUDqaHJNYfS MUjfdW1ZiyEtQ7Db9PtZAv4fS5W2W/0NTmEbw45985kBDzRfdvG4Jgm/PYeY066LPM 7MZ8hFOKC3rh31OgDSEFRWNCsU49TaQg1bLi4e2lOCIPiYdC65wzGMWKGqXkSt5MTz ObUejPQ6mb045O/mMc29hcdx+FJ64G9GuKXDY4wcjxPVPi+r7jiF8h5/6W79MxcpBm ltn+M+KYtzFEVlb8Km22Mx3ubzrnaWXv3J/GK/LfMvyann1RJBbhZ81zLbFmzgn2pV pQiIB+3DxJ87A== From: "Rafael J. Wysocki" To: netdev@vger.kernel.org Cc: LKML , Linux ACPI , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2] net: fjes: Drop fjes_acpi_driver and rework initialization Date: Wed, 18 Mar 2026 14:43:55 +0100 Message-ID: <12857407.O9o76ZdvQC@rafael.j.wysocki> Organization: Linux Kernel Development 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" From: "Rafael J. Wysocki" The ACPI driver interface used by the Fujitsu Extended Socket (fjes) Network Device driver is redundant because its only role is to create a platform device the fjes platform driver can bind to, which can be done already at the module initialization time. Namely, acpi_find_extended_socket_device() looks for the requisite ACPI device object anyway and it may as well check its resources, and the platform device can be created when the ACPI object in question has been found (and it can be freed when the module is unloaded). Moreover, as a rule, it is better to avoid binding drivers directly to ACPI device objects [1]. Accordingly, drop fjes_acpi_driver, adjust the module initialization and exit code as per the above and set the fwnode for the fjes platform device to point to the corresponding ACPI device object as its ACPI companion. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] Signed-off-by: Rafael J. Wysocki Reviewed-by: Simon Horman --- v1 -> v2: Add platform device unregistration to the rollback path in fjes_init_module, as per https://lore.kernel.org/linux-acpi/CAJZ5v0g9BinHfQDS6hUvVHdLxDPvbv7ck=3Dm1B= qa=3D+C3iE+vgxw@mail.gmail.com/ --- drivers/net/fjes/fjes_main.c | 120 +++++++++++++++-------------------- 1 file changed, 50 insertions(+), 70 deletions(-) diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c index b63965d9a1ba..1f0f38980549 100644 --- a/drivers/net/fjes/fjes_main.c +++ b/drivers/net/fjes/fjes_main.c @@ -111,56 +111,6 @@ fjes_get_acpi_resource(struct acpi_resource *acpi_res,= void *data) return AE_OK; } =20 -static struct resource fjes_resource[] =3D { - DEFINE_RES_MEM(0, 1), - DEFINE_RES_IRQ(0) -}; - -static int fjes_acpi_add(struct acpi_device *device) -{ - struct platform_device *plat_dev; - acpi_status status; - - if (!is_extended_socket_device(device)) - return -ENODEV; - - if (acpi_check_extended_socket_status(device)) - return -ENODEV; - - status =3D acpi_walk_resources(device->handle, METHOD_NAME__CRS, - fjes_get_acpi_resource, fjes_resource); - if (ACPI_FAILURE(status)) - return -ENODEV; - - /* create platform_device */ - plat_dev =3D platform_device_register_simple(DRV_NAME, 0, fjes_resource, - ARRAY_SIZE(fjes_resource)); - if (IS_ERR(plat_dev)) - return PTR_ERR(plat_dev); - - device->driver_data =3D plat_dev; - - return 0; -} - -static void fjes_acpi_remove(struct acpi_device *device) -{ - struct platform_device *plat_dev; - - plat_dev =3D (struct platform_device *)acpi_driver_data(device); - platform_device_unregister(plat_dev); -} - -static struct acpi_driver fjes_acpi_driver =3D { - .name =3D DRV_NAME, - .class =3D DRV_NAME, - .ids =3D fjes_acpi_ids, - .ops =3D { - .add =3D fjes_acpi_add, - .remove =3D fjes_acpi_remove, - }, -}; - static int fjes_setup_resources(struct fjes_adapter *adapter) { struct net_device *netdev =3D adapter->netdev; @@ -1470,43 +1420,81 @@ static struct platform_driver fjes_driver =3D { .remove =3D fjes_remove, }; =20 +struct fjes_acpi_walk_context { + struct acpi_device *adev; + struct resource resources[2]; +}; + static acpi_status acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level, void *context, void **return_value) { + struct fjes_acpi_walk_context *fjes_context =3D context; struct acpi_device *device; - bool *found =3D context; + acpi_status status; =20 - device =3D acpi_fetch_acpi_dev(obj_handle); + device =3D acpi_get_acpi_dev(obj_handle); if (!device) return AE_OK; =20 if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID)) - return AE_OK; + goto skip; =20 if (!is_extended_socket_device(device)) - return AE_OK; + goto skip; =20 if (acpi_check_extended_socket_status(device)) - return AE_OK; + goto skip; + + status =3D acpi_walk_resources(obj_handle, METHOD_NAME__CRS, + fjes_get_acpi_resource, fjes_context->resources); + if (ACPI_FAILURE(status)) + goto skip; + + fjes_context->adev =3D device; =20 - *found =3D true; return AE_CTRL_TERMINATE; + +skip: + acpi_dev_put(device); + return AE_OK; } =20 +static struct platform_device *fjes_plat_dev; + /* fjes_init_module - Driver Registration Routine */ static int __init fjes_init_module(void) { - bool found =3D false; + struct fjes_acpi_walk_context fjes_context =3D { + .adev =3D NULL, + .resources =3D { + DEFINE_RES_MEM(0, 1), + DEFINE_RES_IRQ(0) + } + }; + struct platform_device_info pdevinfo; int result; =20 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - acpi_find_extended_socket_device, NULL, &found, + acpi_find_extended_socket_device, NULL, &fjes_context, NULL); - - if (!found) + if (!fjes_context.adev) return -ENODEV; =20 + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + pdevinfo.name =3D DRV_NAME; + pdevinfo.res =3D fjes_context.resources; + pdevinfo.num_res =3D ARRAY_SIZE(fjes_context.resources); + pdevinfo.fwnode =3D acpi_fwnode_handle(fjes_context.adev); + + fjes_plat_dev =3D platform_device_register_full(&pdevinfo); + + acpi_dev_put(fjes_context.adev); + + if (IS_ERR(fjes_plat_dev)) + return PTR_ERR(fjes_plat_dev); + pr_info("%s - version %s - %s\n", fjes_driver_string, fjes_driver_version, fjes_copyright); =20 @@ -1515,19 +1503,11 @@ static int __init fjes_init_module(void) result =3D platform_driver_register(&fjes_driver); if (result < 0) { fjes_dbg_exit(); + platform_device_unregister(fjes_plat_dev); return result; } =20 - result =3D acpi_bus_register_driver(&fjes_acpi_driver); - if (result < 0) - goto fail_acpi_driver; - return 0; - -fail_acpi_driver: - platform_driver_unregister(&fjes_driver); - fjes_dbg_exit(); - return result; } =20 module_init(fjes_init_module); @@ -1535,9 +1515,9 @@ module_init(fjes_init_module); /* fjes_exit_module - Driver Exit Cleanup Routine */ static void __exit fjes_exit_module(void) { - acpi_bus_unregister_driver(&fjes_acpi_driver); platform_driver_unregister(&fjes_driver); fjes_dbg_exit(); + platform_device_unregister(fjes_plat_dev); } =20 module_exit(fjes_exit_module); --=20 2.51.0