Re: [PATCH linux v7 4/6] hwmon: occ: Add callbacks for parsing P8 OCC datastructures
From: Andrew Jeffery
Date: Sun Feb 12 2017 - 20:17:37 EST
On Fri, 2017-02-10 at 16:01 +1030, Joel Stanley wrote:
> > On Wed, Feb 8, 2017 at 9:40 AM,ÂÂ<eajames@xxxxxxxxxxxxxxxxxx> wrote:
> > > > From: "Edward A. James" <eajames@xxxxxxxxxx>
> >
> > Add functions to parse the data structures that are specific to the OCC on
> > the POWER8 processor. These are the sensor data structures, including
> > temperature, frequency, power, and "caps."
> >
> > > > Signed-off-by: Edward A. James <eajames@xxxxxxxxxx>
> > > > Signed-off-by: Andrew Jeffery <andrew@xxxxxxxx>
> > ---
> > ÂDocumentation/hwmon/occÂÂÂÂ|ÂÂÂ9 ++
> > Âdrivers/hwmon/occ/occ_p8.c | 248 +++++++++++++++++++++++++++++++++++++++++++++
> > Âdrivers/hwmon/occ/occ_p8.h |ÂÂ30 ++++++
> > Â3 files changed, 287 insertions(+)
> > Âcreate mode 100644 drivers/hwmon/occ/occ_p8.c
> > Âcreate mode 100644 drivers/hwmon/occ/occ_p8.h
> >
> > diff --git a/drivers/hwmon/occ/occ_p8.c b/drivers/hwmon/occ/occ_p8.c
> > new file mode 100644
> > index 0000000..5c61fc4
> > --- /dev/null
> > +++ b/drivers/hwmon/occ/occ_p8.c
> > +void p8_parse_sensor(u8 *data, void *sensor, int sensor_type, int off,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint snum)
> > +{
> > +ÂÂÂÂÂÂÂswitch (sensor_type) {
> > +ÂÂÂÂÂÂÂcase FREQ:
> > +ÂÂÂÂÂÂÂcase TEMP:
> > +ÂÂÂÂÂÂÂ{
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂstruct p8_occ_sensor *os =
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ&(((struct p8_occ_sensor *)sensor)[snum]);
> > +
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂos->sensor_id = be16_to_cpu(get_unaligned((u16 *)&data[off]));
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂos->value = be16_to_cpu(get_unaligned((u16 *)&data[off + 2]));
> > +ÂÂÂÂÂÂÂ}
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak;
> > +ÂÂÂÂÂÂÂcase POWER:
> > +ÂÂÂÂÂÂÂ{
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂstruct p8_power_sensor *ps =
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ&(((struct p8_power_sensor *)sensor)[snum]);
> > +
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂps->sensor_id = be16_to_cpu(get_unaligned((u16 *)&data[off]));
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂps->update_tag =
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbe32_to_cpu(get_unaligned((u32 *)&data[off + 2]));
>
> This might be more readable if you wrote a
> cast_get_unaliged_be32_to_cpu() macro.
>
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂps->accumulator =
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbe32_to_cpu(get_unaligned((u32 *)&data[off + 6]));
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂps->value = be16_to_cpu(get_unaligned((u16 *)&data[off + 10]));
> > +ÂÂÂÂÂÂÂ}
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak;
> > +ÂÂÂÂÂÂÂcase CAPS:
> > +ÂÂÂÂÂÂÂ{
> > +const u32 *p8_get_sensor_hwmon_configs()
> > +{
> > +ÂÂÂÂÂÂÂreturn p8_sensor_hwmon_configs;
> > +}
> > +EXPORT_SYMBOL(p8_get_sensor_hwmon_configs);
> > +
> > +struct occ *p8_occ_start(struct device *dev, void *bus,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂstruct occ_bus_ops *bus_ops)
> > +{
> > +ÂÂÂÂÂÂÂreturn occ_start(dev, bus, bus_ops, &p8_ops, &p8_config);
> > +}
> > +EXPORT_SYMBOL(p8_occ_start);
>
> We don't need to export these symbols; they're not used outside of the
> OCC module. The same goes for all of the exports you've made in this
> series.
Sorry, this was my doing in an attempt to get everything to build as
modules rather than just built-in. I should have studied
Documentation/kbuild/modules.txt a bit more.
>
> I suggest we re-architect the drivers so we build all of the objects
> and link them into one module for each platform, instead of having an
> occ module and occ-p8/occ-p9 modules and i2c modules that all depend
> on each other. The Makefile could look like this:
>
> obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += hwmon_occ_p8.o
> obj-$(CONFIG_SENSORS_PPC_OCC_P9) += hwmon_occ_p9.o
>
> hwmon_occ_p8-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o
> occ_p8.o p8_occ_i2c.o occ_sysfs.o occ.o
> hwmon_occ_p9-$(CONFIG_SENSORS_PPC_OCC_P9) += occ_p9.o occ_sysfs.o occ.o
>
> And the Kbuild like this:
>
> menuconfig SENSORS_PPC_OCC
> ÂÂÂÂÂÂÂÂbool "PPC On-Chip Controller"
>
> if SENSORS_PPC_OCC
>
> config SENSORS_PPC_OCC_P8_I2C
> ÂÂÂÂÂÂÂÂbool "POWER8 OCC hwmon support"
> ÂÂÂÂÂÂÂÂdepends on I2C
>
> config SENSORS_PPC_OCC_P9
> ÂÂÂÂÂÂÂÂbool "POWER9 OCC hwmon support"
>
> endif
Given we can drop the exports that's a much more sensible idea.
AndrewAttachment:
signature.asc
Description: This is a digitally signed message part