On Sat, Apr 6, 2024 at 3:53 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote: > > Add a new driver for the custom fast charging protocol found on Lenovo Yoga > Tablet 2 1380F / 1380L models. ... > +#include <linux/delay.h> + err.h + errno.h > +#include <linux/extcon.h> > +#include <linux/gpio/consumer.h> + mod_devicetable.h > +#include <linux/module.h> > +#include <linux/notifier.h> > +#include <linux/pinctrl/consumer.h> > +#include <linux/pinctrl/machine.h> > +#include <linux/platform_device.h> > +#include <linux/serdev.h> + types.h > +#include <linux/workqueue.h> > +#include "serdev_helpers.h" ... > +#define YT2_1380_FC_PIN_SW_DELAY_US 10000 > +#define YT2_1380_FC_UART_DRAIN_DELAY_US 50000 > +#define YT2_1380_FC_VOLT_SW_DELAY_US 1000000 Hmm... perhaps 10 * USEC_PER_MSEC 50 * USEC_PER_MSEC 1 * USEC_PER_SEC ? ... > +static bool yt2_1380_fc_dedicated_charger_connected(struct yt2_1380_fc *fc) > +{ > + int ret; > + > + ret = extcon_get_state(fc->extcon, EXTCON_CHG_USB_DCP); > + return ret > 0; This and other functions can be shorter by eliminating the ret variable, but it's up to you. > +} ... > + ret = serdev_device_write_buf(to_serdev_device(fc->dev), "SC", 2); Hmm... I would replace magic 2 in both cases by strlen("SC") or so. > + if (ret != 2) { > + dev_err(fc->dev, "Error %d writing to uart\n", ret); > + return; > + } ... > +static struct platform_driver yt2_1380_fc_pdev_driver = { > + .probe = yt2_1380_fc_pdev_probe, > + .remove_new = yt2_1380_fc_pdev_remove, > + .driver = { > + .name = YT2_1380_FC_PDEV_NAME, > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + }, + .id_table = ... (see below why) > +}; > +MODULE_ALIAS("platform:" YT2_1380_FC_PDEV_NAME); The _standard_ MODULE_ALIAS() is not an excuse to have no ID table. Just provide an accurate platform device ID table instead. -- With Best Regards, Andy Shevchenko