Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp217201rdb; Thu, 8 Feb 2024 04:09:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVdPdhJylZ7ZMue4e0xhfGmhRirc/ewepzFnRuCNHOVsH3f2cYbCg99Grukhxq/LbQt03ooYUVyTjg5bqCCwsI2KyN/90Gy0bS0sQc9g== X-Google-Smtp-Source: AGHT+IFt2e+x5FXjoO58f61mXQ/PwNF98QPU31ql8OOj6YtLrBorMX2V9E7eiBYCE2ZJ2JbpGzgv X-Received: by 2002:a17:906:b208:b0:a38:71e8:3182 with SMTP id p8-20020a170906b20800b00a3871e83182mr3521659ejz.23.1707394155276; Thu, 08 Feb 2024 04:09:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394155; cv=pass; d=google.com; s=arc-20160816; b=I68mEK41Jcm+1Q7Ct1QdG0dQ9F1pBHHizePvVTZBYt2Vr09Hr1ImzTC5kbadOgDtPQ 4hDS6CoWwWpbCTL27dkHBkC/DFAF+KNJPwQFGM24KIeGT6YrVSReX0euCOjiRhUwtnro FuoKOLHA4ovAdKTdKMxLeNubQTGRTOhkKGrWAx4gbKdNLycDLb5U2H+YktM5pcnrC0pA OWpVU/1bHHptscMJh658oS/Grb2LdbqRyDWq5hADWDmOisC60QKk19XJBsrI9LH8FZcP Zd0mhnbryZ24Ae1FUrU/r0cfgiThS31N8Ep+8BYAfs3en2cmg+MvGVIuhtOvbXqCBkMW Y0ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j5/mVJpPoztezPCsCahTirdZ41pbMSJcEU4xNyX/97Y=; fh=4iUMgzIk8FcG7+01uhaMDBHn3ZVSwB0Q85VRIUr+2Yo=; b=RqZTF0uV2ftpTYSRCUkhsTYmlvcOUAj2DWf8FhLGFfJI3rQV2z75tSIKIzc3djD07Q Rd8ELPD6e13EOywkDQP4Z7HywBbUjQWgACUaF89q5e007ExZLd6TD4E0GjnPMsDzxYMX +PLjb4iTbbE8NdsvbN2bSX1m65eT7VFcMJzu0XNTOpHPq+4QMCS4LuX9F4w0k8NymHdh r87awUCi2E4n3lCitkFdNWm2zRxwzBUjldziuz51UzdVKIOi/Twcd/fewDK4VQZ8wxLN eCdkY78dUgNkiTt7tPF1sp7Jkmf2vBi+GecmRzPv8kJGE2DCySGoQN273C+NGb3/dg14 +MWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TUSSU38v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXuzaiKsuzN1eSoDqzrca7t/yPAjNNpeVE9aFoDt4W6BE4hgyBo+EW4ExpQk9CerRrmiDhreHJLNJ1JQND38Fs/DPw7w7jSknLBMI2MKw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pk7-20020a170906d7a700b00a35a09a326dsi2076936ejb.961.2024.02.08.04.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TUSSU38v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D5AA51F233F7 for ; Thu, 8 Feb 2024 12:09:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52E4271B2E; Thu, 8 Feb 2024 12:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TUSSU38v" 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 6CF916E2C9; Thu, 8 Feb 2024 12:09:06 +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=1707394146; cv=none; b=EMM/8rqQfUtEfgbccV+OUoJu0UNw9gR94F17YS1rFo77gZLa83nak74j+6FQF/HyZdL2zcZzZXZVhkgR6wc87b+KAEhS/ZydaTWIMqW/5t1vmgAB0fxfpRNVuKvRsJ2ndqwsQaiQ50z/dYU8brUR9iL8jC8Hus1mEHQR4F0pzJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707394146; c=relaxed/simple; bh=3MMu0Y0CQdulA1m2A3YQhoiuTaMYOljYq8OdGTWMeL0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lSiTyOVrVC1un6+ItJzmUAM9y3uUrFEkDRVDCoq1HYpqbOXiv4NQBwUTVSQk7SgG24TC0lxxwY4Tu/5D+3OIZyKtupESU/8cjHYdFVdUGjcfvJ5kYg4bM6mRBFEkXJpyJencbuUXP58hJmsbb3rocthkLqzF7wlrRvjotar5qrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TUSSU38v; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EF47C433C7; Thu, 8 Feb 2024 12:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707394145; bh=3MMu0Y0CQdulA1m2A3YQhoiuTaMYOljYq8OdGTWMeL0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TUSSU38veRFJ+Rx7rU48pMBZsjFYDKTOeZQw+rv26zxOdSn4iZne0n+H9Yz8Br4D2 1eDdDBVgP99RfEIms2Cu+Y3SqTp3JahXmknTq2efrcc4jZoZRfChd8SU1Y+7XmYT2j pNTdzOy3XaYyLUhQ6y4HbVnXmO/kKAhD/UOFxfx3XVkP+8jeIuO4rMkJZMjrQvbdnz 1SJB0P4DufJq9gj9vK/cpwWaJ9J3SlXPLVX94euxlmyd1nZOuSb86OiX6TdSsHxbjc RM567eHHKDvXUXf6U9aoFq23Xs1LLgD3P3PftiIBzS/teEb2M/pvbYIk+mvXlI0EVW 5dy9hG5NQ/YBg== Date: Thu, 8 Feb 2024 12:09:01 +0000 From: Lee Jones To: Xing Tong Wu Cc: Pavel Machek , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Hans de Goede , Xing Tong Wu , Tobias Schaffner , Gerd Haeussler , Henning Schild Subject: Re: [PATCH RESEND 1/1] leds: simatic-ipc-leds-gpio: add support for module BX-59A Message-ID: <20240208120901.GL689448@google.com> References: <20240204083048.2458-1-xingtong_wu@163.com> <20240204083048.2458-2-xingtong_wu@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240204083048.2458-2-xingtong_wu@163.com> On Sun, 04 Feb 2024, Xing Tong Wu wrote: > From: Xing Tong Wu > > This is used for the Siemens Simatic IPC BX-59A, which has its LEDs > connected to GPIOs provided by the Nuvoton NCT6126D > > Signed-off-by: Xing Tong Wu > --- > .../leds/simple/simatic-ipc-leds-gpio-core.c | 1 + > .../simple/simatic-ipc-leds-gpio-f7188x.c | 42 ++++++++++++++++--- > 2 files changed, 37 insertions(+), 6 deletions(-) > > diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c > index 667ba1bc3a30..85003fd7f1aa 100644 > --- a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c > +++ b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c > @@ -56,6 +56,7 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev, > case SIMATIC_IPC_DEVICE_127E: > case SIMATIC_IPC_DEVICE_227G: > case SIMATIC_IPC_DEVICE_BX_21A: > + case SIMATIC_IPC_DEVICE_BX_59A: > break; > default: > return -ENODEV; > diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c > index c7c3a1f986e6..783e74e9a805 100644 > --- a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c > +++ b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c > @@ -17,7 +17,10 @@ > > #include "simatic-ipc-leds-gpio.h" > > -static struct gpiod_lookup_table simatic_ipc_led_gpio_table = { > +static struct gpiod_lookup_table *led_lookup_table; > +static struct gpiod_lookup_table *led_lookup_table_extra; No globals please. Dynamically create them in .probe(). If you need to use them later use dev_{s,g}et_drvdata. > +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = { > .dev_id = "leds-gpio", > .table = { > GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW), > @@ -30,7 +33,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table = { > }, > }; > > -static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = { > +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra_227g = { > .dev_id = NULL, /* Filled during initialization */ > .table = { > GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH), > @@ -39,16 +42,43 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = { > }, > }; > > +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_bx_59a = { > + .dev_id = "leds-gpio", > + .table = { > + GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW), > + GPIO_LOOKUP_IDX("gpio-f7188x-2", 3, NULL, 1, GPIO_ACTIVE_LOW), > + GPIO_LOOKUP_IDX("gpio-f7188x-5", 3, NULL, 2, GPIO_ACTIVE_LOW), > + GPIO_LOOKUP_IDX("gpio-f7188x-5", 2, NULL, 3, GPIO_ACTIVE_LOW), > + GPIO_LOOKUP_IDX("gpio-f7188x-7", 7, NULL, 4, GPIO_ACTIVE_LOW), > + GPIO_LOOKUP_IDX("gpio-f7188x-7", 4, NULL, 5, GPIO_ACTIVE_LOW), > + {} /* Terminating entry */ > + } > +}; > + > static int simatic_ipc_leds_gpio_f7188x_probe(struct platform_device *pdev) > { > - return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table, > - &simatic_ipc_led_gpio_table_extra); > + const struct simatic_ipc_platform *plat = pdev->dev.platform_data; > + > + switch (plat->devmode) { > + case SIMATIC_IPC_DEVICE_227G: > + led_lookup_table = &simatic_ipc_led_gpio_table_227g; > + led_lookup_table_extra = &simatic_ipc_led_gpio_table_extra_227g; > + break; > + case SIMATIC_IPC_DEVICE_BX_59A: > + led_lookup_table = &simatic_ipc_led_gpio_table_bx_59a; > + break; > + default: > + return -ENODEV; > + } > + > + return simatic_ipc_leds_gpio_probe(pdev, led_lookup_table, > + led_lookup_table_extra); > } > > static void simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev) > { > - simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, > - &simatic_ipc_led_gpio_table_extra); > + simatic_ipc_leds_gpio_remove(pdev, led_lookup_table, > + led_lookup_table_extra); > } > > static struct platform_driver simatic_ipc_led_gpio_driver = { > -- > 2.25.1 > -- Lee Jones [李琼斯]