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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230407183504.54706458@jic23-huawei>
Date:   Fri, 7 Apr 2023 18:35:04 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Lars-Peter Clausen <lars@...afoo.de>
Cc:     Nicolas Frattaroli <frattaroli.nicolas@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] iio: dac: mcp4922: add support for mcp48xx series
 chips

On Wed, 5 Apr 2023 07:18:46 -0700
Lars-Peter Clausen <lars@...afoo.de> wrote:

> Hi,
> 
> Looks very good. A few small comments inline.
> [...]
> > @@ -50,6 +58,35 @@ struct mcp4922_state {
> >   	},						\
> >   }
> >   
> > +static bool mcp4922_needs_vref(int device_id)  
> 
> `enum mcp4922_supported_device_ids` instead of `int`. Same for num_channels() below.
> 
> > +{
> > +	switch (device_id) {
> > +	case ID_MCP4902:
> > +	case ID_MCP4912:
> > +	case ID_MCP4921:
> > +	case ID_MCP4922:
> > +		return true;
> > +	default:
> > +		return false;
> > +	}
> > +}
> > [...]
> >   static int mcp4922_spi_write(struct mcp4922_state *state, u8 addr, u32 val)
> >   {
> >   	state->mosi[1] = val & 0xff;
> > @@ -108,11 +145,17 @@ static int mcp4922_write_raw(struct iio_dev *indio_dev,
> >   	}
> >   }
> >   
> > -static const struct iio_chan_spec mcp4922_channels[4][MCP4922_NUM_CHANNELS] = {
> > +static const struct iio_chan_spec mcp4922_channels[10][MCP4922_NUM_CHANNELS] = {  
> 
> mcp4922_channels[][MCP4922_NUM_CHANNELS]
> 
> So it does not have to be changed again when adding additional devices 
> in the future.
> 
> > [...]
> > @@ -197,11 +244,14 @@ static void mcp4922_remove(struct spi_device *spi)
> >   {
> >   	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >   	struct mcp4922_state *state;
> > +	const struct spi_device_id *id = spi_get_device_id(spi);
> >   
> >   	iio_device_unregister(indio_dev);
> >   	state = iio_priv(indio_dev);
> >   	regulator_disable(state->vdd_reg);
> > -	regulator_disable(state->vref_reg);
> > +	if (mcp4922_needs_vref(id->driver_data)) {  
> Could be `if (state->vref_reg)`, this way you don't need to lookup the 
> spi_device_id. But either way is fine.

Even better would be to make this driver use devm_ for all unwinding.
That way the regulator_disable() callback registered via
devm_add_action_or_reset() will only be registered if you enabled such
a regulator in the first place.

The rest of this remove is trivial so it would be a nice addition to this
series to get rid of the need to have it at all.

> > +		regulator_disable(state->vref_reg);
> > +	}
> >   }
> >   
> > [...]  
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ