From nobody Sun Oct 5 01:52:48 2025 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 7A91A2E36EC; Mon, 11 Aug 2025 04:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754886704; cv=none; b=KEJJdvDb0MOmb5HXoXK3owbqT644j/dMdcaVwvy2a4CaC6x7GZxr+0C+O0wWZopBuUQtAv8N5t5Hqwbn6q12tffvrhptLJK7EeN/pFO4yS02sXQgIthYNn+wnST96IQbR+eyN+3Ksj0QEcGTWiN9CY4J3cgb29BdOtKdi3KDo0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754886704; c=relaxed/simple; bh=9jhQOGVHQSqrFgET5ndbks6uqT7zenqk32zCi2L313I=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=rVFs6JabH49E2ujy7ZNe+vWDJNMy13pKOytNdQ5meSzk9L7DgfQl2rOk5O7hOI+har89uzHeS60N+w0L7FNnnACyqhb7oeHYkY8pKShU1QFvCxfGMjVebzKMWJm4oionGjKknw4ql1wizF+3kfQNhsDdUJqpCRGOaHywoqWiRvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S0JuVKhA; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S0JuVKhA" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-24003ed822cso22389605ad.1; Sun, 10 Aug 2025 21:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754886701; x=1755491501; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=2KSIxzg7N5siQOaz/snNAUdpqjxAxtIvx/sSJBvLYGc=; b=S0JuVKhAjZwDc+/V8bMxDZuvdlRgdIadAKh83bXuL7ETuvf5xS15l9XEyq1Yne3s4N gcGR1z7y0ifbWOaOoNOl0olFWGBUZZJdT4OHGyD1JafgmhFEclJo1cWI+T6LRPcYInoY QO4G4BSLBJIe0/Foywm4oUEElrWLgu92GVPCdy1r72ZKYGQwhCir4nhlfVVpH/CzI3HJ RzOfMywwmH0YjrhsvAV9KZjVkPjH2M6Em89txPym07YibJQdo1w35LW+j6DT4nhvrcxx XgzJTmVSxwQb2zx0A9+bGk/9ur7vp4GEzX1byCvKvrNysfltw8r+C/P1kyGBPePjC8qJ Yj1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754886701; x=1755491501; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2KSIxzg7N5siQOaz/snNAUdpqjxAxtIvx/sSJBvLYGc=; b=JbTpaK3poDMdlBRaR12RLI/FNbuf1ZQ27eG82VLsw7mvyXsNChOKIAgnTfpl8nqUoS I+D2UX6h/4OjNfKpr1NPvGrpnXyiGBhK0XMJj1mn7mqTKOg0IhswnsEqHXUs2+AOFn7B i3AoocWJdbM1VbSylii1yfkRh3yu4pQ4i45cMhrh1ogT+tpjFT1sftQXfDs3nhKPquvM NgBFl1r59IKl2wm2OLE5df+xYwmPCmnQmUfnUn3f3Xn33yzsMmvQ30zHVvsvnzNCMvYm iTzTNB7+NTb4uu9ffUw4yvu7ZDJ4zvHgEYaxdv01CEESpq+pP1i6Z9FW1S3MSLs6tBGG MB4g== X-Forwarded-Encrypted: i=1; AJvYcCUzWDpkt9dpfleUbj6Ey5OLwYory5fL31RUdi7rO3lFq8CANDQCj58JaEAr7Scu2gs8EBYaabWwdRc94YHU7vIscfEK5g==@vger.kernel.org, AJvYcCXEjKg/DEiAK+/4Zw7JHVv2PCk/cLbMKnzeQlDcd0ff7OTYc5rq3PSYWqhovg4eOtpzQJEQgF8pKGeNjkI=@vger.kernel.org X-Gm-Message-State: AOJu0YxIe1/3VXZEdX3pgp0eE7kSmk0cBAiu1zny7A5XQNmMGvjnwkP/ a2FZFby8DnfANiLdQ3BSOUn7cAWqfLv6C0y/4VBwPDxWegFxZsY8ui6p X-Gm-Gg: ASbGncu1GeVSeZ7NqxOjQC9OOKuHIVVAKI0uemPVQsmg4ebFIvD9oLF7/MEPWI+WPh4 hig67TcvF/J1jHyBiMkwnjfNlSdG1eGDfQdQeRNFghG2doOpMmhqdd5sy5gyoC/WSq2JgbBD4uG mjS+V2Nh2qkFJdi+SGhquGlNg27g7JJBmN5EfEWb7aRJEf6E6ijRieytahQJTUNDsfr6zDXDtxO Mwz9Oj520YyB2uR8zJRo0NC8sfxVf8CSbww+eGIokKk4PGAKte0e7Rbyv0q2maDfistH0z21rxo 33x2hxgQRAqixBJCTgK//jtNNeIP9RvuUnesapX7ANen2fsO1i4y7DvI8svrMgxCYspe062W4NF G7h6OHfPndosHG6ctE2eKmNg= X-Google-Smtp-Source: AGHT+IGMSbJjyvC5x/Q9BBK55d1A3AH4P45mzdebf0h428MMT29Dqng2oH+AUinVYjhogPFHeFsmcQ== X-Received: by 2002:a17:903:3b87:b0:240:86b2:aecf with SMTP id d9443c01a7336-242c1fdb118mr148969965ad.12.1754886700507; Sun, 10 Aug 2025 21:31:40 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:69d7:30de:b05e:915b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-241e899a51esm263338555ad.115.2025.08.10.21.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:31:40 -0700 (PDT) Date: Sun, 10 Aug 2025 21:31:37 -0700 From: Dmitry Torokhov To: Santosh Kumar Yadav , Hans de Goede Cc: Peter Korsgaard , Bartosz Golaszewski , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , Arnd Bergmann , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: barco-p50-gpio: use software nodes for gpio-leds/keys Message-ID: <2meuzip4qnxvle4bwk4hbow4j34ii3cwb46xd5inq5btif5mjg@iiygy6ir7vtr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation of dropping support for legacy GPIO API from gpio-keys switch the driver to use software nodes/properties to describe GPIO-connected LED and button. Signed-off-by: Dmitry Torokhov --- This is untested - no hardware. drivers/platform/x86/barco-p50-gpio.c | 104 +++++++++++++++----------- 1 file changed, 62 insertions(+), 42 deletions(-) diff --git a/drivers/platform/x86/barco-p50-gpio.c b/drivers/platform/x86/b= arco-p50-gpio.c index 28012eebdb10..6f13e81f98fb 100644 --- a/drivers/platform/x86/barco-p50-gpio.c +++ b/drivers/platform/x86/barco-p50-gpio.c @@ -11,6 +11,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include +#include #include #include #include @@ -18,10 +19,11 @@ #include #include #include -#include #include #include -#include +#include +#include +#include =20 =20 #define DRIVER_NAME "barco-p50-gpio" @@ -78,44 +80,57 @@ static const char * const gpio_names[] =3D { [P50_GPIO_LINE_BTN] =3D "identify-button", }; =20 - -static struct gpiod_lookup_table p50_gpio_led_table =3D { - .dev_id =3D "leds-gpio", - .table =3D { - GPIO_LOOKUP_IDX(DRIVER_NAME, P50_GPIO_LINE_LED, NULL, 0, GPIO_ACTIVE_HIG= H), - {} - } +static const struct software_node gpiochip_node =3D { + .name =3D DRIVER_NAME, }; =20 /* GPIO LEDs */ -static struct gpio_led leds[] =3D { - { .name =3D "identify" } +static const struct software_node gpio_leds_node =3D { + .name =3D "gpio-leds-identify", }; =20 -static struct gpio_led_platform_data leds_pdata =3D { - .num_leds =3D ARRAY_SIZE(leds), - .leds =3D leds, +static const struct property_entry identify_led_props[] =3D { + PROPERTY_ENTRY_GPIO("gpios", &gpiochip_node, P50_GPIO_LINE_LED, GPIO_ACTI= VE_HIGH), + { } +}; + +static const struct software_node identify_led_node =3D { + .parent =3D &gpio_leds_node, + .name =3D "identify", + .properties =3D identify_led_props, }; =20 /* GPIO keyboard */ -static struct gpio_keys_button buttons[] =3D { - { - .code =3D KEY_VENDOR, - .gpio =3D P50_GPIO_LINE_BTN, - .active_low =3D 1, - .type =3D EV_KEY, - .value =3D 1, - }, +static const struct property_entry gpio_keys_props[] =3D { + PROPERTY_ENTRY_STRING("label", "identify"), + PROPERTY_ENTRY_U32("poll-interval", 100), + { } }; =20 -static struct gpio_keys_platform_data keys_pdata =3D { - .buttons =3D buttons, - .nbuttons =3D ARRAY_SIZE(buttons), - .poll_interval =3D 100, - .rep =3D 0, - .name =3D "identify", +static const struct software_node gpio_keys_node =3D { + .name =3D "gpio-keys-identify", + .properties =3D gpio_keys_props, }; =20 +static struct property_entry vendor_key_props[] =3D { + PROPERTY_ENTRY_U32("linux,code", KEY_VENDOR), + PROPERTY_ENTRY_GPIO("gpios", &gpiochip_node, P50_GPIO_LINE_BTN, GPIO_ACTI= VE_LOW), + { } +}; + +static const struct software_node vendor_key_node =3D { + .parent =3D &gpio_keys_node, + .properties =3D vendor_key_props, +}; + +static const struct software_node *p50_swnodes[] =3D { + &gpiochip_node, + &gpio_leds_node, + &identify_led_node, + &gpio_keys_node, + &vendor_key_node, + NULL +}; =20 /* low level access routines */ =20 @@ -285,6 +300,16 @@ static int p50_gpio_set(struct gpio_chip *gc, unsigned= int offset, int value) =20 static int p50_gpio_probe(struct platform_device *pdev) { + struct platform_device_info key_info =3D { + .name =3D "gpio-keys-polled", + .id =3D PLATFORM_DEVID_NONE, + .parent =3D &pdev->dev, + }; + struct platform_device_info led_info =3D { + .name =3D "leds-gpio", + .id =3D PLATFORM_DEVID_NONE, + .parent =3D &pdev->dev, + }; struct p50_gpio *p50; struct resource *res; int ret; @@ -339,25 +364,20 @@ static int p50_gpio_probe(struct platform_device *pde= v) return ret; } =20 - gpiod_add_lookup_table(&p50_gpio_led_table); - - p50->leds_pdev =3D platform_device_register_data(&pdev->dev, - "leds-gpio", PLATFORM_DEVID_NONE, &leds_pdata, sizeof(leds_pdata)); + ret =3D software_node_register_node_group(p50_swnodes); + if (ret) + return dev_err_probe(&pdev->dev, ret, "failed to register software nodes= "); =20 + led_info.fwnode =3D software_node_fwnode(&gpio_leds_node); + p50->leds_pdev =3D platform_device_register_full(&led_info); if (IS_ERR(p50->leds_pdev)) { ret =3D PTR_ERR(p50->leds_pdev); dev_err(&pdev->dev, "Could not register leds-gpio: %d\n", ret); goto err_leds; } =20 - /* gpio-keys-polled uses old-style gpio interface, pass the right identif= ier */ - buttons[0].gpio +=3D p50->gc.base; - - p50->keys_pdev =3D - platform_device_register_data(&pdev->dev, "gpio-keys-polled", - PLATFORM_DEVID_NONE, - &keys_pdata, sizeof(keys_pdata)); - + key_info.fwnode =3D software_node_fwnode(&gpio_keys_node); + p50->keys_pdev =3D platform_device_register_full(&key_info); if (IS_ERR(p50->keys_pdev)) { ret =3D PTR_ERR(p50->keys_pdev); dev_err(&pdev->dev, "Could not register gpio-keys-polled: %d\n", ret); @@ -369,7 +389,7 @@ static int p50_gpio_probe(struct platform_device *pdev) err_keys: platform_device_unregister(p50->leds_pdev); err_leds: - gpiod_remove_lookup_table(&p50_gpio_led_table); + software_node_unregister_node_group(p50_swnodes); =20 return ret; } @@ -381,7 +401,7 @@ static void p50_gpio_remove(struct platform_device *pde= v) platform_device_unregister(p50->keys_pdev); platform_device_unregister(p50->leds_pdev); =20 - gpiod_remove_lookup_table(&p50_gpio_led_table); + software_node_unregister_node_group(p50_swnodes); } =20 static struct platform_driver p50_gpio_driver =3D { --=20 2.51.0.rc0.155.g4a0f42376b-goog --=20 Dmitry