lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e358bc76-a06a-47dc-1729-cf1a8b6e5e27@roeck-us.net>
Date:   Tue, 25 May 2021 21:04:27 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Erik Rosen <erik.rosen@...ormote.com>,
        Jean Delvare <jdelvare@...e.com>,
        Jonathan Corbet <corbet@....net>, linux-hwmon@...r.kernel.org,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/6] hwmon: (pmbus/pim4328) Add function for reading
 direct mode coefficients

On 5/24/21 8:02 AM, Erik Rosen wrote:
> Add the function pmbus_read_coefficients to pmbus_core to be able to
> read and decode the coefficients for the direct format for a certain
> command.
> 
> Signed-off-by: Erik Rosen <erik.rosen@...ormote.com>
> ---
>   drivers/hwmon/pmbus/pmbus.h      |  4 ++++
>   drivers/hwmon/pmbus/pmbus_core.c | 38 ++++++++++++++++++++++++++++++++
>   2 files changed, 42 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index 3968924f8533..d9ed9736b480 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -499,6 +499,10 @@ int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id,
>   			      enum pmbus_fan_mode mode);
>   int pmbus_update_fan(struct i2c_client *client, int page, int id,
>   		     u8 config, u8 mask, u16 command);
> +int pmbus_read_coefficients(struct i2c_client *client,
> +			    struct pmbus_driver_info *info,
> +			    enum pmbus_sensor_classes sensor_class,
> +			    u8 command);
>   struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client);
>   
>   #endif /* PMBUS_H */
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index cb885efc4fba..460cbfd716e4 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -301,6 +301,44 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id,
>   }
>   EXPORT_SYMBOL_NS_GPL(pmbus_update_fan, PMBUS);
>   
> +/*
> + * Read the coefficients for direct mode.
> + */
> +int pmbus_read_coefficients(struct i2c_client *client,
> +			    struct pmbus_driver_info *info,
> +			    enum pmbus_sensor_classes sensor_class,
> +			    u8 command)
> +{
> +	int rv;
> +	union i2c_smbus_data data;
> +	s8 R;
> +	s16 m, b;
> +
> +	data.block[0] = 2;
> +	data.block[1] = command;
> +	data.block[2] = 0x01;
> +
> +	rv = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
> +			    I2C_SMBUS_WRITE, PMBUS_COEFFICIENTS,
> +			    I2C_SMBUS_BLOCK_PROC_CALL, &data);
> +
> +	if (rv < 0)
> +		return rv;
> +
> +	if (data.block[0] != 5)
> +		return -EIO;
> +
> +	m = data.block[1] | (data.block[2] << 8);
> +	b = data.block[3] | (data.block[4] << 8);
> +	R = data.block[5];
> +	info->m[sensor_class] = m;
> +	info->b[sensor_class] = b;
> +	info->R[sensor_class] = R;
> +
> +	return rv;
> +}
> +EXPORT_SYMBOL_NS_GPL(pmbus_read_coefficients, PMBUS);

I don't think this function needs to be exported.
> +
>   int pmbus_read_word_data(struct i2c_client *client, int page, int phase, u8 reg)
>   {
>   	int rv;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ