Skip to content

Commit

Permalink
Merge tag 'tag-chrome-platform-for-v6.4' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Tzung-Bi Shih:
 "Improvements:

   - Replace fake flexible arrays with flexible-array member

  Misc:

   - Minor cleanups and fixes"

* tag 'tag-chrome-platform-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: wilco_ec: remove return value check of debugfs_create_dir()
  platform/chrome: cros_ec_debugfs: fix kernel-doc warning
  platform/chrome: cros_ec: Separate logic for getting panic info
  platform/chrome: cros_typec_switch: Add missing fwnode_handle_put()
  platform/chrome: cros_ec: remove unneeded label and if-condition
  platform/chrome: Replace fake flexible arrays with flexible-array member
  • Loading branch information
torvalds committed Apr 25, 2023
2 parents 4ea9569 + d184d60 commit 07d971a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
10 changes: 4 additions & 6 deletions drivers/platform/chrome/cros_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
err = cros_ec_query_all(ec_dev);
if (err) {
dev_err(dev, "Cannot identify the EC: error %d\n", err);
goto destroy_mutex;
goto exit;
}

if (ec_dev->irq > 0) {
Expand All @@ -218,7 +218,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
if (err) {
dev_err(dev, "Failed to request IRQ %d: %d\n",
ec_dev->irq, err);
goto destroy_mutex;
goto exit;
}
}

Expand All @@ -230,7 +230,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
dev_err(ec_dev->dev,
"Failed to create CrOS EC platform device\n");
err = PTR_ERR(ec_dev->ec);
goto destroy_mutex;
goto exit;
}

if (ec_dev->max_passthru) {
Expand Down Expand Up @@ -296,7 +296,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
exit:
platform_device_unregister(ec_dev->ec);
platform_device_unregister(ec_dev->pd);
destroy_mutex:
mutex_destroy(&ec_dev->lock);
lockdep_unregister_key(&ec_dev->lockdep_key);
return err;
Expand All @@ -313,8 +312,7 @@ EXPORT_SYMBOL(cros_ec_register);
*/
void cros_ec_unregister(struct cros_ec_device *ec_dev)
{
if (ec_dev->pd)
platform_device_unregister(ec_dev->pd);
platform_device_unregister(ec_dev->pd);
platform_device_unregister(ec_dev->ec);
mutex_destroy(&ec_dev->lock);
lockdep_unregister_key(&ec_dev->lockdep_key);
Expand Down
42 changes: 33 additions & 9 deletions drivers/platform/chrome/cros_ec_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,24 +400,48 @@ static void cros_ec_cleanup_console_log(struct cros_ec_debugfs *debug_info)
}
}

static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
/*
* Returns the size of the panicinfo data fetched from the EC
*/
static int cros_ec_get_panicinfo(struct cros_ec_device *ec_dev, uint8_t *data,
int data_size)
{
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
int ret;
struct cros_ec_command *msg;
int insize;

insize = ec_dev->max_response;
if (!data || data_size <= 0 || data_size > ec_dev->max_response)
return -EINVAL;

msg = devm_kzalloc(debug_info->ec->dev,
sizeof(*msg) + insize, GFP_KERNEL);
msg = kzalloc(sizeof(*msg) + data_size, GFP_KERNEL);
if (!msg)
return -ENOMEM;

msg->command = EC_CMD_GET_PANIC_INFO;
msg->insize = insize;
msg->insize = data_size;

ret = cros_ec_cmd_xfer_status(ec_dev, msg);
if (ret < 0)
goto free;

memcpy(data, msg->data, data_size);

free:
kfree(msg);
return ret;
}

static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
{
struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
int ret;
void *data;

data = devm_kzalloc(debug_info->ec->dev, ec_dev->max_response,
GFP_KERNEL);
if (!data)
return -ENOMEM;

ret = cros_ec_get_panicinfo(ec_dev, data, ec_dev->max_response);
if (ret < 0) {
ret = 0;
goto free;
Expand All @@ -427,7 +451,7 @@ static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
if (ret == 0)
goto free;

debug_info->panicinfo_blob.data = msg->data;
debug_info->panicinfo_blob.data = data;
debug_info->panicinfo_blob.size = ret;

debugfs_create_blob("panicinfo", S_IFREG | 0444, debug_info->dir,
Expand All @@ -436,7 +460,7 @@ static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
return 0;

free:
devm_kfree(debug_info->ec->dev, msg);
devm_kfree(debug_info->ec->dev, data);
return ret;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/platform/chrome/cros_typec_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)

return 0;
err_switch:
fwnode_handle_put(fwnode);
cros_typec_unregister_switches(sdata);
return ret;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/platform/chrome/wilco_ec/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ static int wilco_ec_debugfs_probe(struct platform_device *pdev)
return 0;
debug_info->ec = ec;
debug_info->dir = debugfs_create_dir("wilco_ec", NULL);
if (!debug_info->dir)
return 0;
debugfs_create_file("raw", 0644, debug_info->dir, NULL, &fops_raw);
debugfs_create_file("h1_gpio", 0444, debug_info->dir, ec,
&fops_h1_gpio);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/platform_data/cros_ec_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,7 @@ struct ec_response_motion_sense {
* Sensor data is truncated if response_max is too small
* for holding all the data.
*/
struct ec_response_motion_sensor_data sensor[0];
DECLARE_FLEX_ARRAY(struct ec_response_motion_sensor_data, sensor);
} dump;

/* Used for MOTIONSENSE_CMD_INFO. */
Expand Down

0 comments on commit 07d971a

Please sign in to comment.