Re: [PATCH v1 3/3] misc: Add meta cld driver

From: Greg Kroah-Hartman
Date: Tue Jan 17 2023 - 05:16:36 EST


On Tue, Jan 17, 2023 at 05:44:22PM +0800, Delphine CC Chiu wrote:
> Add support for meta control-logic-device driver. The CLD manages the
> server system power squence and other state such as host-power-state,
> uart-selection and presense-slots. The baseboard management controller
> (BMC) can access the CLD through I2C.
>
> The version 1 of CLD driver is supported. The registers number, name
> and mode of CLD can be defined in dts file for version 1. The driver
> exports the filesystem following the dts setting.
>
> Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@xxxxxxxxxx>
> Tested-by: Bonnie Lo <Bonnie_Lo@xxxxxxxxxx>
> ---
> MAINTAINERS | 6 +
> drivers/misc/Kconfig | 9 +
> drivers/misc/Makefile | 1 +
> drivers/misc/control-logic-device.c | 443 ++++++++++++++++++++++++++++

That is a very generic name for a very specific driver. Please make it
more hardware-specific.

Also, you add a bunch of undocumented sysfs files here, which require a
Documentation/ABI/ entries so that we can review the code to verify it
does what you all think it does.

And finally, why is this needed to be a kernel driver at all? Why can't
you control this all through the userspace i2c api?

One review comment:

> +static int cld_remove(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct cld_client *cld = dev_get_drvdata(dev);
> +
> + if (cld->task) {
> + kthread_stop(cld->task);
> + cld->task = NULL;
> + }
> +
> + devm_kfree(dev, cld);

Whenever you see this line in code, it's almost always a huge red flag
that someone is not using the devm_* api properly. I think that is most
certainly the case here.

thanks,

greg k-h