linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Samuel Kayode <samuel.kayode@savoirfairelinux.com>,
	Lee Jones <lee@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Sebastian Reichel <sre@kernel.org>,
	Robin Gong <yibin.gong@nxp.com>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-imx@nxp.com, linux-input@vger.kernel.org,
	Abel Vesa <abelvesa@linux.com>, Abel Vesa <abel.vesa@nxp.com>,
	Robin Gong <b38343@freescale.com>,
	Enric Balletbo Serra <eballetbo@gmail.com>
Subject: Re: [PATCH v2 5/9] mfd: pf1550: add core mfd driver
Date: Sat, 17 May 2025 13:18:47 +0200	[thread overview]
Message-ID: <0c84a24a-2dbe-4c8f-80b1-2e1531fd4ec1@kernel.org> (raw)
In-Reply-To: <85004e02a5177aef6334fc30494bb3924a58f1de.1747409892.git.samuel.kayode@savoirfairelinux.com>

On 16/05/2025 20:54, Samuel Kayode wrote:
> +
> +static int pf1550_i2c_probe(struct i2c_client *i2c)
> +{
> +	struct pf1550_dev *pf1550;
> +	unsigned int reg_data = 0;
> +	int ret = 0;
> +
> +	pf1550 = devm_kzalloc(&i2c->dev,
> +			      sizeof(struct pf1550_dev), GFP_KERNEL);

sizeof(*)

> +	if (!pf1550)
> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(i2c, pf1550);
> +	pf1550->dev = &i2c->dev;
> +	pf1550->i2c = i2c;
> +	pf1550->irq = i2c->irq;
> +
> +	pf1550->regmap = devm_regmap_init_i2c(i2c, &pf1550_regmap_config);
> +	if (IS_ERR(pf1550->regmap)) {
> +		ret = PTR_ERR(pf1550->regmap);
> +		dev_err(pf1550->dev, "failed to allocate register map: %d\n",
> +			ret);


Syntax is always: return dev_err_probe

> +		return ret;
> +	}
> +
> +	ret = regmap_read(pf1550->regmap, PF1550_PMIC_REG_DEVICE_ID, &reg_data);
> +	if (ret < 0 || reg_data != PF1550_DEVICE_ID) {
> +		dev_err(pf1550->dev, "device not found!\n");
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	pf1550->type = PF1550;
> +	dev_info(pf1550->dev, "pf1550 found.\n");

Drop. Drivers should be silent. This is really useless and just pollutes
log. See also coding style.

> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_regulator_irq_chip,
> +				&pf1550->irq_data_regulator);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq1 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_onkey_irq_chip,
> +				&pf1550->irq_data_onkey);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq3 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_charger_irq_chip,
> +				&pf1550->irq_data_charger);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq4 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	return devm_mfd_add_devices(pf1550->dev, -1, pf1550_devs,
> +			      ARRAY_SIZE(pf1550_devs), NULL, 0, NULL);
> +}
> +
> +static const struct i2c_device_id pf1550_i2c_id[] = {
> +	{ "pf1550", PF1550 },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(i2c, pf1550_i2c_id);

Table IDs are next to each other.

> +
> +static int pf1550_suspend(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct pf1550_dev *pf1550 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev)) {
> +		enable_irq_wake(pf1550->irq);
> +		disable_irq(pf1550->irq);
> +	}
> +
> +	return 0;
> +}
> +
> +static int pf1550_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct pf1550_dev *pf1550 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev)) {
> +		disable_irq_wake(pf1550->irq);
> +		enable_irq(pf1550->irq);
> +	}
> +
> +	return 0;
> +}
> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(pf1550_pm, pf1550_suspend, pf1550_resume);
> +
> +static const struct of_device_id pf1550_dt_match[] = {
> +	{ .compatible = "fsl,pf1550" },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, pf1550_dt_match);
> +
> +static struct i2c_driver pf1550_i2c_driver = {
> +	.driver = {
> +		   .name = "pf1550",
> +		   .pm = pm_sleep_ptr(&pf1550_pm),
> +		   .of_match_table = of_match_ptr(pf1550_dt_match),


Drop of_match_ptr, you have warnings here.

> +	},
> +	.probe = pf1550_i2c_probe,
> +	.id_table = pf1550_i2c_id,
> +};
> +
> +module_i2c_driver(pf1550_i2c_driver);
> +
> +MODULE_DESCRIPTION("Freescale PF1550 multi-function core driver");
> +MODULE_AUTHOR("Robin Gong <yibin.gong@freescale.com>");
> +MODULE_LICENSE("GPL v2");
Best regards,
Krzysztof

  reply	other threads:[~2025-05-17 11:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 18:29 [PATCH v2 0/9] add support for pf1550 PMIC MFD-based drivers Samuel Kayode
2025-05-16 18:47 ` [PATCH v2 1/9] dt-bindings: power: supply: add pf1550 Samuel Kayode
2025-05-17 11:12   ` Krzysztof Kozlowski
2025-05-16 18:50 ` [PATCH v2 2/9] dt-bindings: regulator: " Samuel Kayode
2025-05-17 11:13   ` Krzysztof Kozlowski
2025-05-16 18:52 ` [PATCH v2 3/9] dt-bindings: input: " Samuel Kayode
2025-05-17 11:14   ` Krzysztof Kozlowski
2025-05-16 18:54 ` [PATCH v2 5/9] mfd: pf1550: add core mfd driver Samuel Kayode
2025-05-17 11:18   ` Krzysztof Kozlowski [this message]
2025-05-20 13:25   ` kernel test robot
2025-05-16 18:55 ` [PATCH v2 6/9] regulator: pf1550: add support for regulator Samuel Kayode
2025-05-17 20:13   ` kernel test robot
2025-05-16 18:57 ` [PATCH v2 7/9] input: pf1550: add onkey support Samuel Kayode
2025-05-16 22:55   ` Dmitry Torokhov
2025-05-21 21:00     ` Samuel Kayode
2025-05-18 16:03   ` kernel test robot
2025-05-16 18:58 ` [PATCH v2 8/9] power: supply: pf1550: add battery charger support Samuel Kayode
2025-05-17 11:20   ` Krzysztof Kozlowski
2025-05-16 18:59 ` [PATCH v2 9/9] MAINTAINERS: add an entry for pf1550 mfd driver Samuel Kayode
     [not found] ` <8be1626f970c9fab8b50ae9ad45e0ddd88fa36bf.1747409892.git.samuel.kayode@savoirfairelinux.com>
     [not found]   ` <31542315-5ea1-4849-b2f9-686cabce914a@kernel.org>
2025-05-21 16:16     ` [PATCH v2 4/9] dt-bindings: mfd: add pf1550 Samuel Kayode
2025-05-21 16:22       ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c84a24a-2dbe-4c8f-80b1-2e1531fd4ec1@kernel.org \
    --to=krzk@kernel.org \
    --cc=abel.vesa@nxp.com \
    --cc=abelvesa@linux.com \
    --cc=b38343@freescale.com \
    --cc=broonie@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eballetbo@gmail.com \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=samuel.kayode@savoirfairelinux.com \
    --cc=sre@kernel.org \
    --cc=yibin.gong@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).