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: <d7bd6663-516a-a1f9-506c-5853eaa948e4@linaro.org>
Date:   Tue, 14 Mar 2023 09:54:11 +0100
From:   Neil Armstrong <neil.armstrong@...aro.org>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
        linux-usb@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v3 01/12] usb: typec: ucsi: add PMIC Glink UCSI driver

On 13/03/2023 10:43, Heikki Krogerus wrote:
> Hi,
> 
> On Thu, Mar 09, 2023 at 02:27:52PM +0100, Neil Armstrong wrote:
>> +static void pmic_glink_ucsi_register(struct work_struct *work)
>> +{
>> +	struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, register_work);
>> +
>> +	ucsi_register(ucsi->ucsi);
>> +}
>> +
>> +static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv)
>> +{
>> +	struct pmic_glink_ucsi *ucsi = priv;
>> +	const struct pmic_glink_hdr *hdr = data;
>> +
>> +	switch (hdr->opcode) {
>> +	case UC_UCSI_READ_BUF_REQ:
>> +		pmic_glink_ucsi_read_ack(ucsi, data, len);
>> +		break;
>> +	case UC_UCSI_WRITE_BUF_REQ:
>> +		pmic_glink_ucsi_write_ack(ucsi, data, len);
>> +		break;
>> +	case UC_UCSI_USBC_NOTIFY_IND:
>> +		schedule_work(&ucsi->notify_work);
>> +		break;
>> +	};
>> +}
>> +
>> +static void pmic_glink_ucsi_pdr_notify(void *priv, int state)
>> +{
>> +	struct pmic_glink_ucsi *ucsi = priv;
>> +
>> +	if (state == SERVREG_SERVICE_STATE_UP)
>> +		schedule_work(&ucsi->register_work);
>> +	else if (state == SERVREG_SERVICE_STATE_DOWN)
>> +		ucsi_unregister(ucsi->ucsi);
>> +}
>> +
>> +static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
>> +				 const struct auxiliary_device_id *id)
>> +{
>> +	struct pmic_glink_ucsi *ucsi;
>> +	struct device *dev = &adev->dev;
>> +
>> +	ucsi = devm_kzalloc(dev, sizeof(*ucsi), GFP_KERNEL);
>> +	if (!ucsi)
>> +		return -ENOMEM;
>> +
>> +	ucsi->dev = dev;
>> +	dev_set_drvdata(dev, ucsi);
>> +
>> +	INIT_WORK(&ucsi->notify_work, pmic_glink_ucsi_notify);
>> +	INIT_WORK(&ucsi->register_work, pmic_glink_ucsi_register);
>> +	init_completion(&ucsi->read_ack);
>> +	init_completion(&ucsi->write_ack);
>> +	init_completion(&ucsi->sync_ack);
>> +	mutex_init(&ucsi->lock);
>> +
>> +	ucsi->ucsi = ucsi_create(dev, &pmic_glink_ucsi_ops);
>> +	if (IS_ERR(ucsi->ucsi))
>> +		return PTR_ERR(ucsi->ucsi);
>> +
>> +	ucsi_set_drvdata(ucsi->ucsi, ucsi);
>> +
>> +	ucsi->client = devm_pmic_glink_register_client(dev,
>> +						       PMIC_GLINK_OWNER_USBC,
>> +						       pmic_glink_ucsi_callback,
>> +						       pmic_glink_ucsi_pdr_notify,
>> +						       ucsi);
>> +	return PTR_ERR_OR_ZERO(ucsi->client);
>> +}
>> +
>> +static const struct auxiliary_device_id pmic_glink_ucsi_id_table[] = {
>> +	{ .name = "pmic_glink.ucsi", },
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(auxiliary, pmic_glink_ucsi_id_table);
>> +
>> +static struct auxiliary_driver pmic_glink_ucsi_driver = {
>> +	.name = "pmic_glink_ucsi",
>> +	.probe = pmic_glink_ucsi_probe,
>> +	.id_table = pmic_glink_ucsi_id_table,
>> +};
> 
> What happens if you remove the module - I think you need to implement
> the remove callback, no?

You're right, I thought devm_pmic_glink_register_client would call
pmic_glink_ucsi_pdr_notify which would unregister ucsi, but no so will add.

Thanks,
Neil

> 
> thanks,
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ