From: Neil Armstrong <neil.armstrong@linaro.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 01/12] usb: typec: ucsi: add PMIC Glink UCSI driver
Date: Tue, 14 Mar 2023 09:54:11 +0100 [thread overview]
Message-ID: <d7bd6663-516a-a1f9-506c-5853eaa948e4@linaro.org> (raw)
In-Reply-To: <ZA7wPtttsWlQRpAR@kuha.fi.intel.com>
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,
>
next prev parent reply other threads:[~2023-03-14 8:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 13:27 [PATCH v3 00/12] soc: qcom: add UCSI function to PMIC GLINK Neil Armstrong
2023-03-09 13:27 ` [PATCH v3 01/12] usb: typec: ucsi: add PMIC Glink UCSI driver Neil Armstrong
2023-03-13 9:43 ` Heikki Krogerus
2023-03-14 8:54 ` Neil Armstrong [this message]
2023-03-09 13:27 ` [PATCH v3 02/12] dt-bindings: soc: qcom: qcom,pmic-glink: document SM8450 compatible Neil Armstrong
2023-03-09 13:27 ` [PATCH v3 03/12] dt-bindings: soc: qcom: qcom,pmic-glink: document SM8550 compatible Neil Armstrong
2023-03-09 13:27 ` [PATCH v3 04/12] soc: qcom: pmic_glink: register ucsi aux device Neil Armstrong
2023-03-10 20:56 ` Dmitry Baryshkov
2023-03-09 13:27 ` [PATCH v3 05/12] dt-bindings: usb: snps,dwc3: document HS & SS OF graph ports Neil Armstrong
2023-03-16 23:03 ` Rob Herring
2023-03-09 13:27 ` [PATCH v3 06/12] arm64: dts: qcom: sm8350: add port subnodes in dwc3 node Neil Armstrong
2023-03-09 13:27 ` [PATCH v3 07/12] arm64: dts: qcom: sm8450: " Neil Armstrong
2023-03-09 13:27 ` [PATCH v3 08/12] arm64: dts: qcom: sm8550: " Neil Armstrong
2023-03-09 13:28 ` [PATCH v3 09/12] arm64: dts: qcom: sm8350-hdk: add pmic glink node Neil Armstrong
2023-03-09 13:28 ` [PATCH v3 10/12] arm64: dts: qcom: sm8450-hdk: " Neil Armstrong
2023-03-09 13:28 ` [PATCH v3 11/12] arm64: dts: qcom: sm8550-mtp: " Neil Armstrong
2023-03-09 13:28 ` [PATCH v3 12/12] arm64: defconfig: add PMIC GLINK modules Neil Armstrong
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=d7bd6663-516a-a1f9-506c-5853eaa948e4@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®