[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241109134538.6f09971d@jic23-huawei>
Date: Sat, 9 Nov 2024 13:45:38 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Yu-Hsian Yang <j2anfernee@...il.com>
Cc: Krzysztof Kozlowski <krzk@...nel.org>, avifishman70@...il.com,
tmaimon77@...il.com, tali.perry1@...il.com, venture@...gle.com,
yuenn@...gle.com, benjaminfair@...gle.com, lars@...afoo.de,
robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
nuno.sa@...log.com, dlechner@...libre.com, javier.carrasco.cruz@...il.com,
andy@...nel.org, marcelo.schmitt@...log.com, olivier.moysan@...s.st.com,
mitrutzceclan@...il.com, matteomartelli3@...il.com, alisadariana@...il.com,
joao.goncalves@...adex.com, marius.cristea@...rochip.com,
mike.looijmans@...ic.nl, chanh@...amperecomputing.com, KWLIU@...oton.com,
yhyang2@...oton.com, openbmc@...ts.ozlabs.org, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/2] iio: adc: add Nuvoton NCT720x ADC driver
On Thu, 7 Nov 2024 08:41:21 +0800
Yu-Hsian Yang <j2anfernee@...il.com> wrote:
> Dear Krzysztof Kozlowski,
>
> Thank you for your response.
>
> Krzysztof Kozlowski <krzk@...nel.org> 於 2024年11月6日 週三 下午9:41寫道:
> >
> > On 06/11/2024 03:39, Eason Yang wrote:
> > > Add Nuvoton NCT7201/NCT7202 system voltage monitor 12-bit ADC driver
> > >
> > > NCT7201/NCT7202 supports up to 12 analog voltage monitor inputs and up to
> > > 4 SMBus addresses by ADDR pin. Meanwhile, ALERT# hardware event pins for
> > > independent alarm signals, and the all threshold values could be set for
> > > system protection without any timing delay. It also supports reset input
> > > RSTIN# to recover system from a fault condition.
> > >
> > > Currently, only single-edge mode conversion and threshold events support.
> > >
> > > Signed-off-by: Eason Yang <j2anfernee@...il.com>
> >
> > ...
> >
> > > +
> > > +static int nct720x_probe(struct i2c_client *client)
> > > +{
> > > + const struct i2c_device_id *id = i2c_client_get_device_id(client);
> > > + struct nct720x_chip_info *chip;
> > > + struct iio_dev *indio_dev;
> > > + int ret;
> > > + u32 tmp;
> > > +
> > > + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
> > > + if (!indio_dev)
> > > + return -ENOMEM;
> > > + chip = iio_priv(indio_dev);
> > > +
> > > + if (client->dev.of_node)
> > > + chip->type = (enum nct720x_chips)device_get_match_data(&client->dev);
> > > + else
> > > + chip->type = i2c_match_id(nct720x_id, client)->driver_data;
> >
> > I believe there is a I2C wrapper for above.
> >
>
> Got it.
Don't pass an enum value as data. Pass a pointer to a structure that describes the particular
variant. The 0 value which tends to end up in enums is an error for device_get_match_data.
>
> > > +
> > > + chip->vin_max = (chip->type == nct7201) ? NCT7201_VIN_MAX : NCT7202_VIN_MAX;
> > > +
> > > + ret = of_property_read_u32(client->dev.of_node, "read-vin-data-size", &tmp);
> > > + if (ret < 0) {
> > > + pr_err("read-vin-data-size property not found\n");
> >
> > Please use dev_xxx in your driver code.
>
> Got it.
>
> >
> >
> > Best regards,
> > Krzysztof
> >
Powered by blists - more mailing lists