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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87e26131-7793-49fc-a2be-73126bce86ba@wanadoo.fr>
Date: Wed, 4 Dec 2024 22:59:50 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Dzmitry Sankouski <dsankouski@...il.com>,
 Sebastian Reichel <sre@...nel.org>, Chanwoo Choi <cw00.choi@...sung.com>,
 Krzysztof Kozlowski <krzk@...nel.org>, Lee Jones <lee@...nel.org>,
 Rob Herring <robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
 Dmitry Torokhov <dmitry.torokhov@...il.com>, Pavel Machek <pavel@....cz>,
 Hans de Goede <hdegoede@...hat.com>,
 Marek Szyprowski <m.szyprowski@...sung.com>,
 Sebastian Krzyszkowiak <sebastian.krzyszkowiak@...i.sm>,
 Purism Kernel Team <kernel@...i.sm>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
 devicetree@...r.kernel.org, linux-input@...r.kernel.org,
 linux-leds@...r.kernel.org
Subject: Re: [PATCH v10 7/8] power: supply: max77705: Add charger driver for
 Maxim 77705

Le 04/12/2024 à 21:09, Dzmitry Sankouski a écrit :
> Add driver for Maxim 77705 switch-mode charger (part of max77705
> MFD driver) providing power supply class information to userspace.
> 
> The driver is configured through DTS (battery and system related
> settings).
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@...il.com>
> 
> ---

Hi,

> +static int max77705_check_battery(struct max77705_charger_data *charger, int *val)
> +{
> +	unsigned int reg_data;
> +	unsigned int reg_data2;
> +	struct regmap *regmap = charger->regmap;
> +
> +
> +	regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &reg_data);
> +
> +	dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data);
> +
> +	regmap_read(regmap,
> +			  MAX77705_CHG_REG_DETAILS_00, &reg_data2);

This can fit on a single line, I think.

> +
> +	dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2);
> +
> +	if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS))
> +		*val = true;
> +	else
> +		*val = false;
> +
> +	return 0;
> +}

...

> +static int max77705_get_input_current(struct max77705_charger_data *charger,
> +					int *val)
> +{
> +	unsigned int reg_data;
> +	int get_current = 0;
> +	struct regmap *regmap = charger->regmap;
> +
> +	regmap_read(regmap,
> +			  MAX77705_CHG_REG_CNFG_09, &reg_data);

It can fit on a single line, I think.

> +
> +	reg_data &= MAX77705_CHG_CHGIN_LIM_MASK;
> +
> +	if (reg_data <= 3)
> +		get_current = 100;
> +	else if (reg_data >= MAX77705_CHG_CHGIN_LIM_MASK)
> +		get_current = MAX77705_CURRENT_CHGIN_MAX;
> +	else
> +		get_current = (reg_data + 1) * 25;
> +
> +	*val = get_current;
> +
> +	return 0;
> +}
> +
> +static int max77705_get_charge_current(struct max77705_charger_data *charger,
> +					int *val)
> +{
> +	unsigned int reg_data;
> +	struct regmap *regmap = charger->regmap;
> +
> +

No need for to empty lines.

> +	regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, &reg_data);
> +	reg_data &= MAX77705_CHG_CC;
> +
> +	*val = reg_data <= 0x2 ? 100 : reg_data * 50;
> +
> +	return 0;
> +}

...

> +static int max77705_charger_probe(struct platform_device *pdev)
> +{
> +	struct power_supply_config pscfg = {};
> +	struct i2c_client *i2c_chg;
> +	struct max77693_dev *max77705;
> +	struct max77705_charger_data *chg;
> +	struct device *dev, *parent;
> +	struct regmap_irq_chip_data *irq_data;
> +	int ret;
> +
> +	dev = &pdev->dev;
> +	parent = dev->parent;
> +	max77705 = dev_get_drvdata(parent);
> +
> +	chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL);
> +	if (!chg)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, chg);
> +
> +	i2c_chg = devm_i2c_new_dummy_device(dev, max77705->i2c->adapter, I2C_ADDR_CHG);
> +	if (IS_ERR(i2c_chg))
> +		return PTR_ERR(i2c_chg);
> +
> +	chg->regmap = devm_regmap_init_i2c(i2c_chg, &max77705_chg_regmap_config);
> +	if (IS_ERR(chg->regmap))
> +		return PTR_ERR(chg->regmap);
> +
> +	chg->dev = dev;
> +
> +	ret = regmap_update_bits(chg->regmap,
> +				MAX77705_CHG_REG_INT_MASK,
> +				MAX77705_CHGIN_IM, 0);
> +	if (ret)
> +		return ret;
> +
> +	pscfg.of_node = dev->of_node;
> +	pscfg.drv_data = chg;
> +
> +	chg->psy_chg = devm_power_supply_register(dev, &max77705_charger_psy_desc, &pscfg);
> +	if (IS_ERR(chg->psy_chg))
> +		return PTR_ERR(chg->psy_chg);
> +
> +	max77705_charger_irq_chip.irq_drv_data = chg;
> +	ret = devm_regmap_add_irq_chip(chg->dev, chg->regmap, max77705->irq,
> +					IRQF_ONESHOT | IRQF_SHARED, 0,
> +					&max77705_charger_irq_chip,
> +					&irq_data);
> +	if (ret)
> +		dev_err_probe(dev, ret, "failed to add irq chip\n");
> +
> +	chg->wqueue = create_singlethread_workqueue(dev_name(dev));
> +	if (IS_ERR(chg->wqueue))
> +		dev_err_probe(dev, PTR_ERR(chg->wqueue), "failed to create workqueue\n");

Is it fine if chg->wqueue is an ERR?
I think that max77705_chgin_irq() won't like it.

Missing return?

Same for the test above. Is it fine to continue if 
devm_regmap_add_irq_chip() fails?

> +
> +	INIT_WORK(&chg->chgin_work, max77705_chgin_isr_work);
> +
> +	max77705_charger_initialize(chg);
> +
> +	ret = devm_add_action_or_reset(dev, max77705_charger_disable, chg);
> +	if (ret)
> +		return ret;
> +
> +	return max77705_charger_enable(chg);
> +}

...

CJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ