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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 5 May 2020 12:15:41 +0100
From:   Mark Brown <broonie@...nel.org>
To:     Leslie Hsia(夏邦進_Pegatron) 
        <Leslie_Hsia@...atroncorp.com>
Cc:     "knaack.h@....de" <knaack.h@....de>,
        "lars@...afoo.de" <lars@...afoo.de>,
        "pmeerw@...erw.net" <pmeerw@...erw.net>,
        "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Hermes Hsieh(謝旻劭_Pegatron) 
        <Hermes_Hsieh@...atroncorp.com>,
        "jesse.sung@...onical.com" <jesse.sung@...onical.com>,
        "jic23@...nel.org" <jic23@...nel.org>
Subject: Re: [PATCH] ASoC: tas5805m: Add TAS5805M amplifier driver

On Tue, May 05, 2020 at 10:36:29AM +0000, Leslie Hsia(夏邦進_Pegatron) wrote:

> +struct tas5805m_priv {
> +       struct regmap *regmap;
> +       /* mutex for getting the mutex and release */
> +       struct mutex lock;
> +};

This actually appears to be for device initialization somehow - the
comment isn't super enlightening.  It's not clear to me that there are
any potential races here - the PM stuff and device probe and removal are
already locked further up the stack.

> +/* Initialize the TAS5805M and set the volume to -6.5db,
> + * and set it to Play mode.
> + */
> +static const struct reg_sequence tas5805m_init_dsp[] = {
> +       { TAS5805M_REG_DEV_CTL2, TAS5805M_DEV_STAT_DSLEEP },
> +       { TAS5805M_REG_DEV_CTL2, TAS5805M_DEV_STAT_HIZ },
> +       { TAS5805M_REG_DEV_CTL2, TAS5805M_DEV_STAT_DSLEEP },
> +       /* set volume to -6.5dB */
> +       { TAS5805M_REG_VOL_CTL,  TAS5805M_DIG_VOL_DB },
> +       { TAS5805M_REG_DEV_CTL2, TAS5805M_DEV_STAT_PLAY },
> +};

You should use the chip defaults unless the configuration is so obvious
that almost all users would want the same setting.  This avoids the
kernel having to take decisions about which use case to support, a
volume that makes sense for one system may not make sense for others.

> +/* Setting the TAS5805M state and save the config in the default page. */
> +static int tas5805m_set_device_state(struct tas5805m_priv *tas5805m,
> +                                       int state)
> +{
> +       int ret = 0;
> +
> +       ret = regmap_write(tas5805m->regmap, TAS5805M_REG_DEV_RESET,
> +                               TAS5805M_DEV_STAT_RESET);
> +       if (ret != 0)
> +               return -EINVAL;
> +
> +       /* Saving the config to the default page of the default book */
> +       ret = regmap_write(tas5805m->regmap,
> +                       TAS5805M_REG_DEV_BOOK,
> +                       TAS5805M_DEV_BOOK_DEFAULT_PAGE);

regmap has support for paging, you should probably describe the pages in
the regmap config.  Right now I don't think things are going to work
well since there are no pages described but caching is enabled which
means that regmap will cache values that are getting paged out.

> +static int tas5805m_i2c_remove(struct i2c_client *i2c)
> +{
> +       return 0;
> +}

You can just delete empty functions like this, if things can safely be
left empty then they can just be removed entirely.

> +MODULE_DEVICE_TABLE(acpi, tas5805m_acpi_match);
> +#else
> +#define st_accel_acpi_match NULL
> +#endif

This is redundant, ACPI_PTR() won't reference the value unless ACPI is
enabled.

> +#else
> +#define tas5805m_dsp_power_pm_ops NULL
> +#endif
> +
> +static struct i2c_driver tas5805m_i2c_driver = {
> +       .driver = {
> +               .name = TAS5805M_DRV_NAME,
> +               .acpi_match_table = ACPI_PTR(tas5805m_acpi_match),
> +               .pm = tas5805m_dsp_power_pm_ops,

Use SET_SYSTEM_SLEEP_PM_OPS() and remove the else case above.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ