Skip to content

Staging/max77958 - #3541

Open
sean-park-pub wants to merge 3 commits into
mainfrom
staging/max77958
Open

sean-park-pub wants to merge 3 commits into
mainfrom
staging/max77958

Conversation

@sean-park-pub

Copy link
Copy Markdown
Collaborator

PR Description

  • Please replace this comment with a summary of your changes, and add any context
    necessary to understand them. List any dependencies required for this change.
  • To check the checkboxes below, insert a 'x' between square brackets (without
    any space), or simply check them after publishing the PR.
  • If you changes include a breaking change, please specify dependent PRs in the
    description and try to push all related PRs simultaneously.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

    Add MAX77958 to KERNEL_ALL_ADI_DRIVERS config to enable
    building the MAX77958 usb/typec driver with the ADI driver collection.

Signed-off-by: Park, Sean <Sean.Park@analog.com>
Signed-off-by: Park, Sean <Sean.Park@analog.com>
@github-actions

This comment was marked as outdated.

Signed-off-by: Park, Sean <Sean.Park@analog.com>
Comment on lines +1142 to +1147
max77958_get_version_info(usbc_data);
max77958_init_irq_handler(usbc_data);

max77958_cc_init(usbc_data);
max77958_bc12_init(usbc_data);
max77958_pd_init(usbc_data);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in the other prs, all may return errors and early, and no proper clean-up is being done; please use devm_* wrappers

}
INIT_WORK(&max77958->wait_apcmd_resp_work, wait_apcmd_resp_work_func);

ret = request_firmware(&fw, MAX77958_FIRMWARE_FILE, &max77958->i2c->dev);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firmware file size is not checked before accessing fw_bin[4] and fw_bin[5], out-of-boundary memory bug if the file is truncated.

dev_err(&max77958->i2c->dev, "Failed to load firmware '%s' (err=%d)\n", MAX77958_FIRMWARE_FILE, ret);
} else {
dev_info(&max77958->i2c->dev, "Firmware '%s' loaded as %zu bytes\n", MAX77958_FIRMWARE_FILE, fw->size);
ret = max77958_usbc_fw_update(max77958, fw->data, fw->size, 0);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ret is never read, what if max77958_usbc_fw_update fails?

err = i2c_smbus_write_i2c_block_data(i2c, addr, len, pbuf);
if (err) {
pr_err("%s : failed(%d) to i2c_smbus_write_i2c_block_data\n", __func__, err);
break;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you break the case, not the outer loop, overwriting the err code.

MAX77958_I2C_BULK_DEBUG(KERN_INFO, strdump, DUMP_PREFIX_NONE, 8, 1, (const void *)pbuf, len, false);
err = i2c_smbus_write_i2c_block_data(i2c, addr, len, pbuf);
if (err) {
pr_err("%s : failed(%d) to i2c_smbus_write_i2c_block_data\n", __func__, err);

@gastmaier gastmaier Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use dev_err, dev_err_probe for device errors, no __func__, there are tracing symbols that do the same.

the dynamic debug with function name is

 echo 'module <MODULE> +pf' > /sys/kernel/debug/dynamic_debug/control

see flags section at
https://docs.kernel.org/admin-guide/dynamic-debug-howto.html

Comment on lines +1053 to +1055
g_usbc_data = usbc_data;
usbc_data->dev = max77958->dev;
usbc_data->max77958 = max77958;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we have two max77958 in the devicetree? the second will overwrite the first. Properly allocate per device probe, be careful with shared global state.
max77958_dev is per device probe, a better location to store state.

return ret;
}

void max77958_usbc_deinit(struct max77958_usbc_platform_data *usbc_data)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delayed work is never cleared. see devm_delayed_work_autocancel to auto cancel

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm review Request a review from a LLM Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants