Re: [PATCH] [PATCH] drivers/hwmon/pmbus/delta.c: Add drivers to Delta's modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The subject should be something like

[PATCH] hwmon: Driver for Delta power supplies

On 9/15/20 6:28 PM, xiao.mx.ma wrote:
> The <drivers/hwmon/pmbus/delta.c> provides drivers for Delta's modules.
> Currently supports Q54SJ108A2 series and other series will continue to
> be added in the future.

Empty line missing here.

> Signed-off-by: xiao.mx.ma <734056705@xxxxxx>

Please drop the excessive empty lines and resubmit. Also see other comments
in the code.

If you don't know how to format the file, I would suggest to use
scripts/Lindent as starting point. That still leaves way too many
empty lines, though. Please look into other files for examples,
and run checkpatch --strict.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/Kconfig  |   8 ++
>  drivers/hwmon/pmbus/Makefile |   1 +
>  drivers/hwmon/pmbus/delta.c  | 234 +++++++++++++++++++++++++++++++++++

Documentation/hwmon/delta.rst missing

>  3 files changed, 243 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/delta.c
> 
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index e35db489b76f..a9468be10d7e 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -45,6 +45,14 @@ config SENSORS_BEL_PFE
>  	  This driver can also be built as a module. If so, the module will
>  	  be called bel-pfe.
>  
> +config SENSORS_DELTA
> +	tristate "DELTA"

Might be better to have a bit more text here. "Delta power suplies", maybe.

> +	help
> +	  If you say yes here you get hardware monitoring support for Delta Power Supplies.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called delta.
> +
>  config SENSORS_IBM_CFFPS
>  	tristate "IBM Common Form Factor Power Supply"
>  	depends on LEDS_CLASS
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index c4b15db996ad..8957f5337002 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_PMBUS)		+= pmbus_core.o
>  obj-$(CONFIG_SENSORS_PMBUS)	+= pmbus.o
>  obj-$(CONFIG_SENSORS_ADM1275)	+= adm1275.o
>  obj-$(CONFIG_SENSORS_BEL_PFE)	+= bel-pfe.o
> +obj-$(CONFIG_SENSORS_DELTA)	+= delta.o
>  obj-$(CONFIG_SENSORS_IBM_CFFPS)	+= ibm-cffps.o
>  obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o
>  obj-$(CONFIG_SENSORS_IR35221)	+= ir35221.o
> diff --git a/drivers/hwmon/pmbus/delta.c b/drivers/hwmon/pmbus/delta.c
> new file mode 100644
> index 000000000000..090429881c45
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/delta.c
> @@ -0,0 +1,234 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +/*
> + * Driver for Q54SJ108A2, Q50SN12050, and Q50SN12072 Integrated, Step-Down
> + * Switching Regulators

This does not match the code.

> + *
> + * Copyright 2020 Delta LLC.
> + */
> +
> +
> +#include <linux/bits.h>
> +
> +#include <linux/err.h>
> +
> +#include <linux/i2c.h>
> +
> +#include <linux/init.h>
> +
> +#include <linux/kernel.h>
> +
> +#include <linux/module.h>
> +
> +#include <linux/mutex.h>
> +
> +#include <linux/of_device.h>
> +
> +#include <linux/pmbus.h>
> +
> +#include <linux/util_macros.h>
> +
> +#include "pmbus.h"
> +
> +enum chips {
> +
> +	Q54SJ108A2
> +};
> +
> +static const struct pmbus_driver_info delta_info[] = {
> +
> +[Q54SJ108A2] = {
> +
> +.pages = 1,
> +
> +/* Source : Delta Q54SJ108A2 */
> +
> +.format[PSC_TEMPERATURE] = linear,
> +
> +.format[PSC_VOLTAGE_IN] = linear,
> +
> +.format[PSC_CURRENT_OUT] = linear,
> +
> +
> +.func[0] = PMBUS_HAVE_VIN |
> +
> +PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +
> +PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +
> +PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> +
> +PMBUS_HAVE_STATUS_INPUT,

Indentation missing.

> +
> +},
> +
> +};
> +
> +
> +
> +static int delta_probe(struct i2c_client *client, const struct i2c_device_id *id)
> +{
> +
> +	struct device *dev = &client->dev;
> +
> +	u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
> +
> +	struct pmbus_driver_info *info;
> +
> +	enum chips chip_id;
> +
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter,
> +
> +		I2C_FUNC_SMBUS_BYTE_DATA |
> +
> +		I2C_FUNC_SMBUS_WORD_DATA |
> +
> +		I2C_FUNC_SMBUS_BLOCK_DATA))
> +
> +		return -ENODEV;
> +
> +	if (client->dev.of_node)
> +
> +		chip_id = (enum chips)of_device_get_match_data(dev);
> +
> +	else
> +
> +		chip_id = id->driver_data;
> +
> +	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
> +
> +	if (ret < 0) {
> +
> +		dev_err(&client->dev, "Failed to read Manufacturer ID\n");
> +
> +		return ret;
> +
> +	}
> +
> +	if (ret != 5 || strncmp((buf), "DELTA", 5)) {

Unnecessary ( ) around buf

> +
> +		buf[ret] = '\0';
> +
> +		dev_err(dev, "Unsupported Manufacturer ID '%s'\n", buf);
> +
> +		return -ENODEV;
> +
> +	}
> +
> +/*
> + * The chips support reading PMBUS_MFR_MODEL.
> + */
> +
> +	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
> +
> +	if (ret < 0) {
> +
> +		dev_err(dev, "Failed to read Manufacturer Model\n");
> +
> +		return ret;
> +
> +	}
> +
> +	if (ret != 14 || strncmp((buf), "Q54SJ108A2", 10)) {

Unnecessary ( ) around buf

> +
> +		buf[ret] = '\0';
> +
> +		dev_err(dev, "Unsupported Manufacturer Model '%s'\n", buf);
> +
> +		return -ENODEV;
> +
> +	}
> +
> +	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_REVISION, buf);
> +
> +	if (ret < 0) {
> +
> +		dev_err(dev, "Failed to read Manufacturer Revision\n");
> +
> +		return ret;
> +
> +	}
> +
> +	if (ret != 4 || buf[0] != 'S') {
> +
> +		buf[ret] = '\0';
> +
> +		dev_err(dev, "Unsupported Manufacturer Revision '%s'\n", buf);
> +
> +		return -ENODEV;
> +
> +	}
> +
> +	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> +
> +	if (!info)
> +
> +		return -ENOMEM;
> +
> +	memcpy(info, &delta_info[chip_id], sizeof(*info));

"info" isn't modified, so there should be no need to copy it.

> +
> +	return pmbus_do_probe(client, id, info);
> +
> +}
> +
> +
> +
> +static const struct i2c_device_id delta_id[] = {
> +
> +{ "Q54SJ108A2", Q54SJ108A2 },
> +
> +{ },
> +

Indentation missing.

> +};
> +
> +
> +
> +MODULE_DEVICE_TABLE(i2c, delta_id);
> +
> +
> +
> +static const struct of_device_id delta_of_match[] = {
> +
> +{ .compatible = "delta,Q54SJ108A2", .data = (void *)Q54SJ108A2 },
> +
> +{ },
> +
Indentation missing

> +};
> +
> +
> +
> +MODULE_DEVICE_TABLE(of, delta_of_match);
> +
> +
> +
> +static struct i2c_driver delta_driver = {
> +
> +.driver = {
> +
> +.name = "Q54SJ108A2",
> +
> +.of_match_table = delta_of_match,
> +
> +},
> +
> +.probe = delta_probe,
> +
> +.remove = pmbus_do_remove,
> +
> +.id_table = delta_id,
> +
Indentation missing

> +};
> +
> +
> +
> +module_i2c_driver(delta_driver);
> +
> +
> +
> +MODULE_AUTHOR("Delta <734056705@xxxxxx>");
> +
> +MODULE_DESCRIPTION("PMBus driver for Delta Q54SJ108A2NCAH / Q54SJ108A2NCDH / Q54SJ108A2NCPG / Q54SJ108A2NCPH");

Does not match code.

> +
> +MODULE_LICENSE("GPL");
> 




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux