From nobody Tue Sep 9 21:10:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10BAEE95A98 for ; Mon, 9 Oct 2023 06:34:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345280AbjJIGe3 (ORCPT ); Mon, 9 Oct 2023 02:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345261AbjJIGeX (ORCPT ); Mon, 9 Oct 2023 02:34:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A68EA6; Sun, 8 Oct 2023 23:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696833259; x=1728369259; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=za/LFqpkgBBSl4wLRNXhwopPBkv+JtSyMcJ1CoIMZbI=; b=A4xH6jOSViqXv7mjcaN5T0bqjf1T8ZJNsEfQZOp2UxZjqR87xfEpPuNG VnKUzNV9hHZ8IecDMZxA0KeKTqbP3cLCsWww5N4zH+lex8179KFhjUqfE 4DT8or2t76GXl8IPgLvsS2KnWITmIb7uTOjH0jyaacLTcru1D4o5qc1d5 rCrylOISRWoH+8JyvKbz3pw1zB1lv4qQYpEwiFzsug+RunnjTcJFXIeLB SgZj+1/NA6ZWX7xXX9uf6nYElqvXxU/qbShiddowLjxt3S0/IWVnF9B3R O1ZEsJFO3BvscppZmucrdh+uQsQUPlQqgw0JySKWfpW39wNsWML940rmi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10857"; a="448273743" X-IronPort-AV: E=Sophos;i="6.03,209,1694761200"; d="scan'208";a="448273743" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2023 23:34:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10857"; a="896654295" X-IronPort-AV: E=Sophos;i="6.03,209,1694761200"; d="scan'208";a="896654295" Received: from shsensorbuild2.sh.intel.com ([10.239.134.197]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2023 23:32:35 -0700 From: Wentong Wu To: gregkh@linuxfoundation.org, oneukum@suse.com, wsa@kernel.org, andi.shyti@linux.intel.com, broonie@kernel.org Cc: bartosz.golaszewski@linaro.org, linus.walleij@linaro.org, hdegoede@redhat.com, linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, sakari.ailus@linux.intel.com, zhifeng.wang@intel.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Wentong Wu Subject: [PATCH v20 4/4] gpio: update Intel LJCA USB GPIO driver Date: Mon, 9 Oct 2023 14:33:25 +0800 Message-Id: <1696833205-16716-5-git-send-email-wentong.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1696833205-16716-1-git-send-email-wentong.wu@intel.com> References: <1696833205-16716-1-git-send-email-wentong.wu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This driver communicate with LJCA GPIO module with specific protocol through interfaces exported by LJCA USB driver. Update the driver according to LJCA USB driver's changes. Signed-off-by: Wentong Wu Reviewed-by: Sakari Ailus Acked-by: Linus Walleij Acked-by: Bartosz Golaszewski Tested-by: Hans de Goede --- drivers/gpio/Kconfig | 4 +- drivers/gpio/gpio-ljca.c | 246 +++++++++++++++++++++++++++----------------= ---- 2 files changed, 145 insertions(+), 105 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 673bafb..8d5b6c3 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1312,9 +1312,9 @@ config GPIO_KEMPLD =20 config GPIO_LJCA tristate "INTEL La Jolla Cove Adapter GPIO support" - depends on MFD_LJCA + depends on USB_LJCA select GPIOLIB_IRQCHIP - default MFD_LJCA + default USB_LJCA help Select this option to enable GPIO driver for the INTEL La Jolla Cove Adapter (LJCA) board. diff --git a/drivers/gpio/gpio-ljca.c b/drivers/gpio/gpio-ljca.c index 87863f0..dfec9fb 100644 --- a/drivers/gpio/gpio-ljca.c +++ b/drivers/gpio/gpio-ljca.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -13,19 +14,18 @@ #include #include #include -#include #include -#include #include #include +#include =20 /* GPIO commands */ -#define LJCA_GPIO_CONFIG 1 -#define LJCA_GPIO_READ 2 -#define LJCA_GPIO_WRITE 3 -#define LJCA_GPIO_INT_EVENT 4 -#define LJCA_GPIO_INT_MASK 5 -#define LJCA_GPIO_INT_UNMASK 6 +#define LJCA_GPIO_CONFIG 1 +#define LJCA_GPIO_READ 2 +#define LJCA_GPIO_WRITE 3 +#define LJCA_GPIO_INT_EVENT 4 +#define LJCA_GPIO_INT_MASK 5 +#define LJCA_GPIO_INT_UNMASK 6 =20 #define LJCA_GPIO_CONF_DISABLE BIT(0) #define LJCA_GPIO_CONF_INPUT BIT(1) @@ -36,45 +36,49 @@ #define LJCA_GPIO_CONF_INTERRUPT BIT(6) #define LJCA_GPIO_INT_TYPE BIT(7) =20 -#define LJCA_GPIO_CONF_EDGE FIELD_PREP(LJCA_GPIO_INT_TYPE, 1) -#define LJCA_GPIO_CONF_LEVEL FIELD_PREP(LJCA_GPIO_INT_TYPE, 0) +#define LJCA_GPIO_CONF_EDGE FIELD_PREP(LJCA_GPIO_INT_TYPE, 1) +#define LJCA_GPIO_CONF_LEVEL FIELD_PREP(LJCA_GPIO_INT_TYPE, 0) =20 /* Intentional overlap with PULLUP / PULLDOWN */ -#define LJCA_GPIO_CONF_SET BIT(3) -#define LJCA_GPIO_CONF_CLR BIT(4) +#define LJCA_GPIO_CONF_SET BIT(3) +#define LJCA_GPIO_CONF_CLR BIT(4) =20 -struct gpio_op { +#define LJCA_GPIO_BUF_SIZE 60u + +struct ljca_gpio_op { u8 index; u8 value; } __packed; =20 -struct gpio_packet { +struct ljca_gpio_packet { u8 num; - struct gpio_op item[]; + struct ljca_gpio_op item[] __counted_by(num); } __packed; =20 -#define LJCA_GPIO_BUF_SIZE 60 struct ljca_gpio_dev { - struct platform_device *pdev; + struct ljca_client *ljca; struct gpio_chip gc; struct ljca_gpio_info *gpio_info; DECLARE_BITMAP(unmasked_irqs, LJCA_MAX_GPIO_NUM); DECLARE_BITMAP(enabled_irqs, LJCA_MAX_GPIO_NUM); DECLARE_BITMAP(reenable_irqs, LJCA_MAX_GPIO_NUM); + DECLARE_BITMAP(output_enabled, LJCA_MAX_GPIO_NUM); u8 *connect_mode; - /* mutex to protect irq bus */ + /* protect irq bus */ struct mutex irq_lock; struct work_struct work; - /* lock to protect package transfer to Hardware */ + /* protect package transfer to hardware */ struct mutex trans_lock; =20 u8 obuf[LJCA_GPIO_BUF_SIZE]; u8 ibuf[LJCA_GPIO_BUF_SIZE]; }; =20 -static int gpio_config(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id, u8 con= fig) +static int ljca_gpio_config(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id, + u8 config) { - struct gpio_packet *packet =3D (struct gpio_packet *)ljca_gpio->obuf; + struct ljca_gpio_packet *packet =3D + (struct ljca_gpio_packet *)ljca_gpio->obuf; int ret; =20 mutex_lock(&ljca_gpio->trans_lock); @@ -82,43 +86,43 @@ static int gpio_config(struct ljca_gpio_dev *ljca_gpio,= u8 gpio_id, u8 config) packet->item[0].value =3D config | ljca_gpio->connect_mode[gpio_id]; packet->num =3D 1; =20 - ret =3D ljca_transfer(ljca_gpio->gpio_info->ljca, LJCA_GPIO_CONFIG, packe= t, - struct_size(packet, item, packet->num), NULL, NULL); + ret =3D ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_CONFIG, (u8 *)packet, + struct_size(packet, item, packet->num), NULL, 0); mutex_unlock(&ljca_gpio->trans_lock); - return ret; + + return ret < 0 ? ret : 0; } =20 static int ljca_gpio_read(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id) { - struct gpio_packet *packet =3D (struct gpio_packet *)ljca_gpio->obuf; - struct gpio_packet *ack_packet =3D (struct gpio_packet *)ljca_gpio->ibuf; - unsigned int ibuf_len =3D LJCA_GPIO_BUF_SIZE; + struct ljca_gpio_packet *ack_packet =3D + (struct ljca_gpio_packet *)ljca_gpio->ibuf; + struct ljca_gpio_packet *packet =3D + (struct ljca_gpio_packet *)ljca_gpio->obuf; int ret; =20 mutex_lock(&ljca_gpio->trans_lock); packet->num =3D 1; packet->item[0].index =3D gpio_id; - ret =3D ljca_transfer(ljca_gpio->gpio_info->ljca, LJCA_GPIO_READ, packet, - struct_size(packet, item, packet->num), ljca_gpio->ibuf, &ibuf_len); - if (ret) - goto out_unlock; - - if (!ibuf_len || ack_packet->num !=3D packet->num) { - dev_err(&ljca_gpio->pdev->dev, "failed gpio_id:%u %u", gpio_id, ack_pack= et->num); - ret =3D -EIO; + ret =3D ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_READ, (u8 *)packet, + struct_size(packet, item, packet->num), + ljca_gpio->ibuf, LJCA_GPIO_BUF_SIZE); + + if (ret <=3D 0 || ack_packet->num !=3D packet->num) { + dev_err(&ljca_gpio->ljca->auxdev.dev, + "read package error, gpio_id: %u num: %u ret: %d\n", + gpio_id, ack_packet->num, ret); + ret =3D ret < 0 ? ret : -EIO; } - -out_unlock: mutex_unlock(&ljca_gpio->trans_lock); - if (ret) - return ret; - return ack_packet->item[0].value > 0; + + return ret < 0 ? ret : ack_packet->item[0].value > 0; } =20 -static int ljca_gpio_write(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id, - int value) +static int ljca_gpio_write(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id, in= t value) { - struct gpio_packet *packet =3D (struct gpio_packet *)ljca_gpio->obuf; + struct ljca_gpio_packet *packet =3D + (struct ljca_gpio_packet *)ljca_gpio->obuf; int ret; =20 mutex_lock(&ljca_gpio->trans_lock); @@ -126,10 +130,11 @@ static int ljca_gpio_write(struct ljca_gpio_dev *ljca= _gpio, u8 gpio_id, packet->item[0].index =3D gpio_id; packet->item[0].value =3D value & 1; =20 - ret =3D ljca_transfer(ljca_gpio->gpio_info->ljca, LJCA_GPIO_WRITE, packet, - struct_size(packet, item, packet->num), NULL, NULL); + ret =3D ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_WRITE, (u8 *)packet, + struct_size(packet, item, packet->num), NULL, 0); mutex_unlock(&ljca_gpio->trans_lock); - return ret; + + return ret < 0 ? ret : 0; } =20 static int ljca_gpio_get_value(struct gpio_chip *chip, unsigned int offset) @@ -147,16 +152,24 @@ static void ljca_gpio_set_value(struct gpio_chip *chi= p, unsigned int offset, =20 ret =3D ljca_gpio_write(ljca_gpio, offset, val); if (ret) - dev_err(chip->parent, "offset:%u val:%d set value failed %d\n", offset, = val, ret); + dev_err(chip->parent, + "set value failed offset: %u val: %d ret: %d\n", + offset, val, ret); } =20 -static int ljca_gpio_direction_input(struct gpio_chip *chip, - unsigned int offset) +static int ljca_gpio_direction_input(struct gpio_chip *chip, unsigned int = offset) { struct ljca_gpio_dev *ljca_gpio =3D gpiochip_get_data(chip); u8 config =3D LJCA_GPIO_CONF_INPUT | LJCA_GPIO_CONF_CLR; + int ret; =20 - return gpio_config(ljca_gpio, offset, config); + ret =3D ljca_gpio_config(ljca_gpio, offset, config); + if (ret) + return ret; + + clear_bit(offset, ljca_gpio->output_enabled); + + return 0; } =20 static int ljca_gpio_direction_output(struct gpio_chip *chip, @@ -166,14 +179,26 @@ static int ljca_gpio_direction_output(struct gpio_chi= p *chip, u8 config =3D LJCA_GPIO_CONF_OUTPUT | LJCA_GPIO_CONF_CLR; int ret; =20 - ret =3D gpio_config(ljca_gpio, offset, config); + ret =3D ljca_gpio_config(ljca_gpio, offset, config); if (ret) return ret; =20 ljca_gpio_set_value(chip, offset, val); + set_bit(offset, ljca_gpio->output_enabled); + return 0; } =20 +static int ljca_gpio_get_direction(struct gpio_chip *chip, unsigned int of= fset) +{ + struct ljca_gpio_dev *ljca_gpio =3D gpiochip_get_data(chip); + + if (test_bit(offset, ljca_gpio->output_enabled)) + return GPIO_LINE_DIRECTION_OUT; + + return GPIO_LINE_DIRECTION_IN; +} + static int ljca_gpio_set_config(struct gpio_chip *chip, unsigned int offse= t, unsigned long config) { @@ -197,7 +222,8 @@ static int ljca_gpio_set_config(struct gpio_chip *chip,= unsigned int offset, return 0; } =20 -static int ljca_gpio_init_valid_mask(struct gpio_chip *chip, unsigned long= *valid_mask, +static int ljca_gpio_init_valid_mask(struct gpio_chip *chip, + unsigned long *valid_mask, unsigned int ngpios) { struct ljca_gpio_dev *ljca_gpio =3D gpiochip_get_data(chip); @@ -208,15 +234,18 @@ static int ljca_gpio_init_valid_mask(struct gpio_chip= *chip, unsigned long *vali return 0; } =20 -static void ljca_gpio_irq_init_valid_mask(struct gpio_chip *chip, unsigned= long *valid_mask, +static void ljca_gpio_irq_init_valid_mask(struct gpio_chip *chip, + unsigned long *valid_mask, unsigned int ngpios) { ljca_gpio_init_valid_mask(chip, valid_mask, ngpios); } =20 -static int ljca_enable_irq(struct ljca_gpio_dev *ljca_gpio, int gpio_id, b= ool enable) +static int ljca_enable_irq(struct ljca_gpio_dev *ljca_gpio, int gpio_id, + bool enable) { - struct gpio_packet *packet =3D (struct gpio_packet *)ljca_gpio->obuf; + struct ljca_gpio_packet *packet =3D + (struct ljca_gpio_packet *)ljca_gpio->obuf; int ret; =20 mutex_lock(&ljca_gpio->trans_lock); @@ -224,18 +253,20 @@ static int ljca_enable_irq(struct ljca_gpio_dev *ljca= _gpio, int gpio_id, bool en packet->item[0].index =3D gpio_id; packet->item[0].value =3D 0; =20 - ret =3D ljca_transfer(ljca_gpio->gpio_info->ljca, - enable ? LJCA_GPIO_INT_UNMASK : LJCA_GPIO_INT_MASK, packet, - struct_size(packet, item, packet->num), NULL, NULL); + ret =3D ljca_transfer(ljca_gpio->ljca, + enable ? LJCA_GPIO_INT_UNMASK : LJCA_GPIO_INT_MASK, + (u8 *)packet, struct_size(packet, item, packet->num), + NULL, 0); mutex_unlock(&ljca_gpio->trans_lock); - return ret; + + return ret < 0 ? ret : 0; } =20 static void ljca_gpio_async(struct work_struct *work) { - struct ljca_gpio_dev *ljca_gpio =3D container_of(work, struct ljca_gpio_d= ev, work); - int gpio_id; - int unmasked; + struct ljca_gpio_dev *ljca_gpio =3D + container_of(work, struct ljca_gpio_dev, work); + int gpio_id, unmasked; =20 for_each_set_bit(gpio_id, ljca_gpio->reenable_irqs, ljca_gpio->gc.ngpio) { clear_bit(gpio_id, ljca_gpio->reenable_irqs); @@ -245,20 +276,22 @@ static void ljca_gpio_async(struct work_struct *work) } } =20 -static void ljca_gpio_event_cb(void *context, u8 cmd, const void *evt_data= , int len) +static void ljca_gpio_event_cb(void *context, u8 cmd, const void *evt_data, + int len) { - const struct gpio_packet *packet =3D evt_data; + const struct ljca_gpio_packet *packet =3D evt_data; struct ljca_gpio_dev *ljca_gpio =3D context; - int i; - int irq; + int i, irq; =20 if (cmd !=3D LJCA_GPIO_INT_EVENT) return; =20 for (i =3D 0; i < packet->num; i++) { - irq =3D irq_find_mapping(ljca_gpio->gc.irq.domain, packet->item[i].index= ); + irq =3D irq_find_mapping(ljca_gpio->gc.irq.domain, + packet->item[i].index); if (!irq) { - dev_err(ljca_gpio->gc.parent, "gpio_id %u does not mapped to IRQ yet\n", + dev_err(ljca_gpio->gc.parent, + "gpio_id %u does not mapped to IRQ yet\n", packet->item[i].index); return; } @@ -299,18 +332,22 @@ static int ljca_irq_set_type(struct irq_data *irqd, u= nsigned int type) ljca_gpio->connect_mode[gpio_id] =3D LJCA_GPIO_CONF_INTERRUPT; switch (type) { case IRQ_TYPE_LEVEL_HIGH: - ljca_gpio->connect_mode[gpio_id] |=3D (LJCA_GPIO_CONF_LEVEL | LJCA_GPIO_= CONF_PULLUP); + ljca_gpio->connect_mode[gpio_id] |=3D + (LJCA_GPIO_CONF_LEVEL | LJCA_GPIO_CONF_PULLUP); break; case IRQ_TYPE_LEVEL_LOW: - ljca_gpio->connect_mode[gpio_id] |=3D (LJCA_GPIO_CONF_LEVEL | LJCA_GPIO_= CONF_PULLDOWN); + ljca_gpio->connect_mode[gpio_id] |=3D + (LJCA_GPIO_CONF_LEVEL | LJCA_GPIO_CONF_PULLDOWN); break; case IRQ_TYPE_EDGE_BOTH: break; case IRQ_TYPE_EDGE_RISING: - ljca_gpio->connect_mode[gpio_id] |=3D (LJCA_GPIO_CONF_EDGE | LJCA_GPIO_C= ONF_PULLUP); + ljca_gpio->connect_mode[gpio_id] |=3D + (LJCA_GPIO_CONF_EDGE | LJCA_GPIO_CONF_PULLUP); break; case IRQ_TYPE_EDGE_FALLING: - ljca_gpio->connect_mode[gpio_id] |=3D (LJCA_GPIO_CONF_EDGE | LJCA_GPIO_C= ONF_PULLDOWN); + ljca_gpio->connect_mode[gpio_id] |=3D + (LJCA_GPIO_CONF_EDGE | LJCA_GPIO_CONF_PULLDOWN); break; default: return -EINVAL; @@ -332,15 +369,14 @@ static void ljca_irq_bus_unlock(struct irq_data *irqd) struct gpio_chip *gc =3D irq_data_get_irq_chip_data(irqd); struct ljca_gpio_dev *ljca_gpio =3D gpiochip_get_data(gc); int gpio_id =3D irqd_to_hwirq(irqd); - int enabled; - int unmasked; + int enabled, unmasked; =20 enabled =3D test_bit(gpio_id, ljca_gpio->enabled_irqs); unmasked =3D test_bit(gpio_id, ljca_gpio->unmasked_irqs); =20 if (enabled !=3D unmasked) { if (unmasked) { - gpio_config(ljca_gpio, gpio_id, 0); + ljca_gpio_config(ljca_gpio, gpio_id, 0); ljca_enable_irq(ljca_gpio, gpio_id, true); set_bit(gpio_id, ljca_gpio->enabled_irqs); } else { @@ -363,43 +399,48 @@ static const struct irq_chip ljca_gpio_irqchip =3D { GPIOCHIP_IRQ_RESOURCE_HELPERS, }; =20 -static int ljca_gpio_probe(struct platform_device *pdev) +static int ljca_gpio_probe(struct auxiliary_device *auxdev, + const struct auxiliary_device_id *aux_dev_id) { + struct ljca_client *ljca =3D auxiliary_dev_to_ljca_client(auxdev); struct ljca_gpio_dev *ljca_gpio; struct gpio_irq_chip *girq; int ret; =20 - ljca_gpio =3D devm_kzalloc(&pdev->dev, sizeof(*ljca_gpio), GFP_KERNEL); + ljca_gpio =3D devm_kzalloc(&auxdev->dev, sizeof(*ljca_gpio), GFP_KERNEL); if (!ljca_gpio) return -ENOMEM; =20 - ljca_gpio->gpio_info =3D dev_get_platdata(&pdev->dev); - ljca_gpio->connect_mode =3D devm_kcalloc(&pdev->dev, ljca_gpio->gpio_info= ->num, - sizeof(*ljca_gpio->connect_mode), GFP_KERNEL); + ljca_gpio->ljca =3D ljca; + ljca_gpio->gpio_info =3D dev_get_platdata(&auxdev->dev); + ljca_gpio->connect_mode =3D devm_kcalloc(&auxdev->dev, + ljca_gpio->gpio_info->num, + sizeof(*ljca_gpio->connect_mode), + GFP_KERNEL); if (!ljca_gpio->connect_mode) return -ENOMEM; =20 mutex_init(&ljca_gpio->irq_lock); mutex_init(&ljca_gpio->trans_lock); - ljca_gpio->pdev =3D pdev; ljca_gpio->gc.direction_input =3D ljca_gpio_direction_input; ljca_gpio->gc.direction_output =3D ljca_gpio_direction_output; + ljca_gpio->gc.get_direction =3D ljca_gpio_get_direction; ljca_gpio->gc.get =3D ljca_gpio_get_value; ljca_gpio->gc.set =3D ljca_gpio_set_value; ljca_gpio->gc.set_config =3D ljca_gpio_set_config; ljca_gpio->gc.init_valid_mask =3D ljca_gpio_init_valid_mask; ljca_gpio->gc.can_sleep =3D true; - ljca_gpio->gc.parent =3D &pdev->dev; + ljca_gpio->gc.parent =3D &auxdev->dev; =20 ljca_gpio->gc.base =3D -1; ljca_gpio->gc.ngpio =3D ljca_gpio->gpio_info->num; - ljca_gpio->gc.label =3D ACPI_COMPANION(&pdev->dev) ? - acpi_dev_name(ACPI_COMPANION(&pdev->dev)) : - dev_name(&pdev->dev); + ljca_gpio->gc.label =3D ACPI_COMPANION(&auxdev->dev) ? + acpi_dev_name(ACPI_COMPANION(&auxdev->dev)) : + dev_name(&auxdev->dev); ljca_gpio->gc.owner =3D THIS_MODULE; =20 - platform_set_drvdata(pdev, ljca_gpio); - ljca_register_event_cb(ljca_gpio->gpio_info->ljca, ljca_gpio_event_cb, lj= ca_gpio); + auxiliary_set_drvdata(auxdev, ljca_gpio); + ljca_register_event_cb(ljca, ljca_gpio_event_cb, ljca_gpio); =20 girq =3D &ljca_gpio->gc.irq; gpio_irq_chip_set_chip(girq, &ljca_gpio_irqchip); @@ -413,7 +454,7 @@ static int ljca_gpio_probe(struct platform_device *pdev) INIT_WORK(&ljca_gpio->work, ljca_gpio_async); ret =3D gpiochip_add_data(&ljca_gpio->gc, ljca_gpio); if (ret) { - ljca_unregister_event_cb(ljca_gpio->gpio_info->ljca); + ljca_unregister_event_cb(ljca); mutex_destroy(&ljca_gpio->irq_lock); mutex_destroy(&ljca_gpio->trans_lock); } @@ -421,34 +462,33 @@ static int ljca_gpio_probe(struct platform_device *pd= ev) return ret; } =20 -static int ljca_gpio_remove(struct platform_device *pdev) +static void ljca_gpio_remove(struct auxiliary_device *auxdev) { - struct ljca_gpio_dev *ljca_gpio =3D platform_get_drvdata(pdev); + struct ljca_gpio_dev *ljca_gpio =3D auxiliary_get_drvdata(auxdev); =20 gpiochip_remove(&ljca_gpio->gc); - ljca_unregister_event_cb(ljca_gpio->gpio_info->ljca); + ljca_unregister_event_cb(ljca_gpio->ljca); + cancel_work_sync(&ljca_gpio->work); mutex_destroy(&ljca_gpio->irq_lock); mutex_destroy(&ljca_gpio->trans_lock); - return 0; } =20 -#define LJCA_GPIO_DRV_NAME "ljca-gpio" -static const struct platform_device_id ljca_gpio_id[] =3D { - { LJCA_GPIO_DRV_NAME, 0 }, - { /* sentinel */ } +static const struct auxiliary_device_id ljca_gpio_id_table[] =3D { + { "usb_ljca.ljca-gpio", 0 }, + { /* sentinel */ }, }; -MODULE_DEVICE_TABLE(platform, ljca_gpio_id); +MODULE_DEVICE_TABLE(auxiliary, ljca_gpio_id_table); =20 -static struct platform_driver ljca_gpio_driver =3D { - .driver.name =3D LJCA_GPIO_DRV_NAME, +static struct auxiliary_driver ljca_gpio_driver =3D { .probe =3D ljca_gpio_probe, .remove =3D ljca_gpio_remove, + .id_table =3D ljca_gpio_id_table, }; -module_platform_driver(ljca_gpio_driver); +module_auxiliary_driver(ljca_gpio_driver); =20 -MODULE_AUTHOR("Ye Xiang "); -MODULE_AUTHOR("Wang Zhifeng "); -MODULE_AUTHOR("Zhang Lixu "); +MODULE_AUTHOR("Wentong Wu "); +MODULE_AUTHOR("Zhifeng Wang "); +MODULE_AUTHOR("Lixu Zhang "); MODULE_DESCRIPTION("Intel La Jolla Cove Adapter USB-GPIO driver"); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(LJCA); --=20 2.7.4