lkml.org 
[lkml]   [2021]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
On 2021-10-29 17:55-0400, Charles Mirabile wrote:
> +static int sensehat_probe(struct i2c_client *i2c,
> + const struct i2c_device_id *id)
> +{
> ...
> +
> + sensehat->joystick.pdev = sensehat_client_dev_register(sensehat,
> + "sensehat-joystick");

Will this not fail the complete driver load if the driver for this single
subdevice is not available?
For example if the Kconfig option has not been selected, the patch for the
driver is not applied or the user has blacklisted the respective module in
their system.

> + if (IS_ERR(sensehat->joystick.pdev)) {
> + dev_err(sensehat->dev, "failed to register sensehat-joystick");
> + return PTR_ERR(sensehat->joystick.pdev);
> + }
> +
> + sensehat->display.pdev = sensehat_client_dev_register(sensehat,
> + "sensehat-display");

Same as above.

> +
> + if (IS_ERR(sensehat->display.pdev)) {
> + dev_err(sensehat->dev, "failed to register sensehat-display");
> + return PTR_ERR(sensehat->display.pdev);
> + }
> +
> + return 0;
> +}
> +
> +static struct platform_device *
> +sensehat_client_dev_register(struct sensehat *sensehat, const char *name)
> +{
> + long ret = -ENOMEM;
> + struct platform_device *pdev = platform_device_alloc(name, -1);
> +
> + if (!pdev)
> + goto alloc_fail;
> +
> + pdev->dev.parent = sensehat->dev;
> + platform_set_drvdata(pdev, sensehat);
> +
> + ret = platform_device_add(pdev);
> + if (ret)
> + goto add_fail;
> +
> + ret = devm_add_action_or_reset(sensehat->dev,
> + (void *)platform_device_unregister, pdev);
> + if (ret)
> + goto alloc_fail;
> +
> + return pdev;
> +
> +add_fail:
> + platform_device_put(pdev);
> +alloc_fail:
> + return ERR_PTR(ret);
> +}

Thomas

\
 
 \ /
  Last update: 2021-10-30 19:21    [W:0.198 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site