From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Ming Yu <a0282524688@gmail.com>
Cc: tmyu0@nuvoton.com, lee@kernel.org, linus.walleij@linaro.org,
brgl@bgdev.pl, andi.shyti@kernel.org, mkl@pengutronix.de,
mailhol.vincent@wanadoo.fr, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, wim@linux-watchdog.org, linux@roeck-us.net,
jdelvare@suse.com, jic23@kernel.org, lars@metafoo.de,
ukleinek@kernel.org, alexandre.belloni@bootlin.com,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-watchdog@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org,
linux-pwm@vger.kernel.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH v1 1/9] mfd: Add core driver for Nuvoton NCT6694
Date: Sat, 26 Oct 2024 16:58:47 +0200 [thread overview]
Message-ID: <5d1c39c3-b686-40ce-b8af-72dfddeb68da@wanadoo.fr> (raw)
In-Reply-To: <20241024085922.133071-2-tmyu0@nuvoton.com>
Le 24/10/2024 à 10:59, Ming Yu a écrit :
> The Nuvoton NCT6694 is a peripheral expander with 16 GPIO chips,
> 6 I2C controllers, 2 CANfd controllers, 2 Watchdog timers, ADC,
> PWM, and RTC.
>
> This driver implements USB device functionality and shares the
> chip's peripherals as a child device.
>
> Each child device can use the USB functions nct6694_read_msg()
> and nct6694_write_msg() to issue a command. They can also register
> a handler function that will be called when the USB device receives
> its interrupt pipe.
>
> Signed-off-by: Ming Yu <tmyu0-KrzQf0k3Iz9BDgjK7y7TUQ@public.gmane.org>
> ---
...
> +static int nct6694_usb_probe(struct usb_interface *iface,
> + const struct usb_device_id *id)
> +{
> + struct usb_device *udev = interface_to_usbdev(iface);
> + struct device *dev = &udev->dev;
> + struct usb_host_interface *interface;
> + struct usb_endpoint_descriptor *int_endpoint;
> + struct nct6694 *nct6694;
> + int pipe, maxp, bulk_pipe;
> + int ret = EINVAL;
Nitpick: no need to init
> +
> + interface = iface->cur_altsetting;
> + /* Binding interface class : 0xFF */
> + if (interface->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
> + interface->desc.bInterfaceSubClass != 0x00 ||
> + interface->desc.bInterfaceProtocol != 0x00)
> + return -ENODEV;
> +
> + int_endpoint = &interface->endpoint[0].desc;
> + if (!usb_endpoint_is_int_in(int_endpoint))
> + return -ENODEV;
> +
> + nct6694 = devm_kzalloc(&udev->dev, sizeof(*nct6694), GFP_KERNEL);
> + if (!nct6694)
> + return -ENOMEM;
> +
> + pipe = usb_rcvintpipe(udev, INT_IN_ENDPOINT);
> + maxp = usb_maxpacket(udev, pipe);
> +
> + nct6694->cmd_buffer = devm_kcalloc(dev, CMD_PACKET_SZ,
> + sizeof(unsigned char), GFP_KERNEL);
> + if (!nct6694->cmd_buffer)
> + return -ENOMEM;
> + nct6694->rx_buffer = devm_kcalloc(dev, MAX_PACKET_SZ,
> + sizeof(unsigned char), GFP_KERNEL);
> + if (!nct6694->rx_buffer)
> + return -ENOMEM;
> + nct6694->tx_buffer = devm_kcalloc(dev, MAX_PACKET_SZ,
> + sizeof(unsigned char), GFP_KERNEL);
> + if (!nct6694->tx_buffer)
> + return -ENOMEM;
> + nct6694->int_buffer = devm_kcalloc(dev, MAX_PACKET_SZ,
> + sizeof(unsigned char), GFP_KERNEL);
> + if (!nct6694->int_buffer)
> + return -ENOMEM;
> +
> + nct6694->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
> + if (!nct6694->int_in_urb) {
> + dev_err(&udev->dev, "Failed to allocate INT-in urb!\n");
> + return -ENOMEM;
> + }
> +
> + /* Bulk pipe maximum packet for each transaction */
> + bulk_pipe = usb_sndbulkpipe(udev, BULK_OUT_ENDPOINT);
> + nct6694->maxp = usb_maxpacket(udev, bulk_pipe);
> +
> + mutex_init(&nct6694->access_lock);
> + nct6694->udev = udev;
> + nct6694->timeout = URB_TIMEOUT; /* Wait until urb complete */
> +
> + INIT_LIST_HEAD(&nct6694->handler_list);
> + spin_lock_init(&nct6694->lock);
> +
> + usb_fill_int_urb(nct6694->int_in_urb, udev, pipe,
> + nct6694->int_buffer, maxp, usb_int_callback,
> + nct6694, int_endpoint->bInterval);
> + ret = usb_submit_urb(nct6694->int_in_urb, GFP_KERNEL);
> + if (ret)
> + goto err_urb;
> +
> + dev_set_drvdata(&udev->dev, nct6694);
> + usb_set_intfdata(iface, nct6694);
> +
> + ret = mfd_add_hotplug_devices(&udev->dev, nct6694_dev,
> + ARRAY_SIZE(nct6694_dev));
> + if (ret) {
> + dev_err(&udev->dev, "Failed to add mfd's child device\n");
> + goto err_mfd;
> + }
> +
> + nct6694->async_workqueue = alloc_ordered_workqueue("asyn_workqueue", 0);
Missing error handling.
> +
> + dev_info(&udev->dev, "Probed device: (%04X:%04X)\n",
> + id->idVendor, id->idProduct);
> + return 0;
> +
> +err_mfd:
> + usb_kill_urb(nct6694->int_in_urb);
> +err_urb:
> + usb_free_urb(nct6694->int_in_urb);
> + return ret;
> +}
> +
> +static void nct6694_usb_disconnect(struct usb_interface *iface)
> +{
> + struct usb_device *udev = interface_to_usbdev(iface);
> + struct nct6694 *nct6694 = usb_get_intfdata(iface);
> +
> + mfd_remove_devices(&udev->dev);
> + flush_workqueue(nct6694->async_workqueue);
> + destroy_workqueue(nct6694->async_workqueue);
> + usb_set_intfdata(iface, NULL);
> + usb_kill_urb(nct6694->int_in_urb);
> + usb_free_urb(nct6694->int_in_urb);
> +}
> +
> +static const struct usb_device_id nct6694_ids[] = {
> + { USB_DEVICE(NCT6694_VENDOR_ID, NCT6694_PRODUCT_ID)},
Nitpick: space missing before the ending }
> + {},
Nitpick: usually, no comma is added after a {} terminator.
> +};
> +MODULE_DEVICE_TABLE(usb, nct6694_ids);
...
CJ
next prev parent reply other threads:[~2024-10-26 15:00 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 8:59 [PATCH v1 0/9] Add Nuvoton NCT6694 MFD devices Ming Yu
2024-10-24 8:59 ` [PATCH v1 1/9] mfd: Add core driver for Nuvoton NCT6694 Ming Yu
2024-10-24 9:03 ` Marc Kleine-Budde
2024-10-25 8:00 ` Ming Yu
2024-10-24 9:57 ` Marc Kleine-Budde
2024-10-25 8:02 ` Ming Yu
2024-10-24 15:20 ` Marc Kleine-Budde
2024-10-24 15:34 ` Marc Kleine-Budde
2024-10-25 8:14 ` Ming Yu
2024-10-25 8:35 ` Marc Kleine-Budde
2024-10-25 9:02 ` Marc Kleine-Budde
2024-10-25 10:22 ` Ming Yu
2024-10-25 8:08 ` Ming Yu
2024-10-25 10:08 ` Marc Kleine-Budde
2024-10-25 11:03 ` Ming Yu
2024-10-25 12:23 ` Marc Kleine-Budde
2024-10-28 7:33 ` Ming Yu
2024-10-28 7:52 ` Marc Kleine-Budde
2024-10-28 8:31 ` Ming Yu
2024-10-28 14:06 ` Marc Kleine-Budde
2024-10-29 3:45 ` Ming Yu
2024-10-29 8:14 ` Marc Kleine-Budde
2024-11-01 5:35 ` Ming Yu
2024-10-26 14:58 ` Christophe JAILLET [this message]
2024-10-28 7:37 ` Ming Yu
2024-10-24 8:59 ` [PATCH v1 2/9] gpio: Add Nuvoton NCT6694 GPIO support Ming Yu
2024-10-24 9:47 ` Bartosz Golaszewski
[not found] ` <CAOoeyxUUOCSaDLK8=ox3hwDVu=Ej-ds4=FsS8F+9GfiE-8HYvg@mail.gmail.com>
2024-10-25 7:12 ` Bartosz Golaszewski
2024-10-25 7:38 ` 游子民
2024-10-25 7:46 ` Bartosz Golaszewski
2024-10-28 8:56 ` Ming Yu
2024-10-30 19:32 ` Bartosz Golaszewski
2024-11-01 6:15 ` Ming Yu
2024-10-24 8:59 ` [PATCH v1 3/9] i2c: Add Nuvoton NCT6694 I2C support Ming Yu
2024-10-24 10:41 ` Andi Shyti
2024-10-25 7:47 ` 游子民
2024-10-24 8:59 ` [PATCH v1 4/9] can: Add Nuvoton NCT6694 CAN support Ming Yu
2024-10-24 12:12 ` Marc Kleine-Budde
2024-10-24 15:28 ` Marc Kleine-Budde
2024-11-01 5:32 ` Ming Yu
2024-10-24 14:17 ` Marc Kleine-Budde
2024-10-24 14:20 ` Marc Kleine-Budde
2024-11-01 1:44 ` Ming Yu
2024-11-01 1:37 ` Ming Yu
2024-10-25 11:18 ` kernel test robot
2024-10-25 23:31 ` kernel test robot
2024-10-24 8:59 ` [PATCH v1 5/9] watchdog: Add Nuvoton NCT6694 WDT support Ming Yu
2024-10-24 15:32 ` Guenter Roeck
2024-10-28 9:49 ` Ming Yu
2024-10-24 16:06 ` Guenter Roeck
2024-10-26 9:19 ` kernel test robot
2024-10-24 8:59 ` [PATCH v1 6/9] hwmon: Add Nuvoton NCT6694 HWMON support Ming Yu
2024-10-24 9:20 ` Kalesh Anakkur Purayil
2024-10-24 14:53 ` Guenter Roeck
2024-10-25 15:22 ` Ming Yu
2024-10-25 15:44 ` Guenter Roeck
2024-10-26 14:50 ` Guenter Roeck
2024-10-28 7:58 ` Ming Yu
2024-10-28 18:54 ` Jonathan Cameron
2024-10-30 3:29 ` Ming Yu
2024-10-30 4:26 ` Guenter Roeck
2024-11-01 6:11 ` Ming Yu
2024-10-28 7:42 ` Ming Yu
2024-10-25 15:10 ` Ming Yu
2024-10-24 15:03 ` Guenter Roeck
2024-10-25 15:33 ` Ming Yu
2024-10-24 8:59 ` [PATCH v1 7/9] iio: adc: Add Nuvoton NCT6694 IIO support Ming Yu
2024-10-26 14:41 ` Jonathan Cameron
2024-11-05 6:21 ` Ming Yu
2024-10-24 8:59 ` [PATCH v1 8/9] pwm: Add Nuvoton NCT6694 PWM support Ming Yu
2024-11-22 18:05 ` Uwe Kleine-König
2024-10-24 8:59 ` [PATCH v1 9/9] rtc: Add Nuvoton NCT6694 RTC support Ming Yu
2024-10-25 23:34 ` Nobuhiro Iwamatsu
2024-10-28 8:42 ` Ming Yu
2024-10-24 11:57 ` [PATCH v1 0/9] Add Nuvoton NCT6694 MFD devices Marc Kleine-Budde
2024-10-25 8:22 ` Ming Yu
2024-10-25 8:33 ` Marc Kleine-Budde
2024-10-30 8:30 ` Ming Yu
2024-10-30 10:12 ` Marc Kleine-Budde
2024-10-30 14:21 ` Ming Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d1c39c3-b686-40ce-b8af-72dfddeb68da@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=a0282524688@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andi.shyti@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=brgl@bgdev.pl \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jdelvare@suse.com \
--cc=jic23@kernel.org \
--cc=kuba@kernel.org \
--cc=lars@metafoo.de \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tmyu0@nuvoton.com \
--cc=ukleinek@kernel.org \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox