Re: [PATCH v11 09/14] HP BIOSCFG driver - enum-attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 23, 2023 at 7:55 AM Thomas Weißschuh <thomas@xxxxxxxx> wrote:
>
> On 2023-04-20 11:54:49-0500, Jorge Lopez wrote:
> >  .../x86/hp/hp-bioscfg/enum-attributes.c       | 543 ++++++++++++++++++
> >  1 file changed, 543 insertions(+)
> >  create mode 100644 drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
> >
> > diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
> > new file mode 100644
> > index 000000000000..20defa92da6f
> > --- /dev/null
> > +++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
> > @@ -0,0 +1,543 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Functions corresponding to enumeration type attributes under
> > + * BIOS Enumeration GUID for use with hp-bioscfg driver.
> > + *
> > + *  Copyright (c) 2022 HP Development Company, L.P.
> > + */
> > +
> > +#include "bioscfg.h"
> > +
> > +GET_INSTANCE_ID(enumeration);
> > +
> > +static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
> > +{
> > +     int instance_id = get_enumeration_instance_id(kobj);
> > +
> > +     if (instance_id < 0)
> > +             return -EIO;
> > +
> > +     return sysfs_emit(buf, "%s\n",
> > +                      bioscfg_drv.enumeration_data[instance_id].current_value);
> > +}
> > +
> > +/*
> > + * validate_enumeration_input() -
> > + * Validate input of current_value against possible values
> > + *
> > + * @instance_id: The instance on which input is validated
> > + * @buf: Input value
> > + */
> > +static int validate_enumeration_input(int instance_id, const char *buf)
> > +{
> > +     int ret = 0;
> > +     int found = 0;
> > +     int i;
> > +     int possible_values;
> > +
> > +     /* Is it a read only attribute */
> > +     if (bioscfg_drv.enumeration_data[instance_id].common.is_readonly)
> > +             return -EIO;
> > +
> > +     possible_values = bioscfg_drv.enumeration_data[instance_id].possible_values_size;
> > +     for (i = 0; i < possible_values && !found; i++)
> > +             if (!strcasecmp(bioscfg_drv.enumeration_data[instance_id].possible_values[i], buf))
>
> Is this also intentionally case-insensitive?

Yes

>
> > +                     found = 1;
> > +
> > +     if (!found) {
> > +             ret = -EINVAL;
> > +             goto exit_enum_input;
> > +     }
> > +
> > +     /*
> > +      * set pending reboot flag depending on
> > +      * "RequiresPhysicalPresence" value
> > +      */
> > +     if (bioscfg_drv.enumeration_data[instance_id].common.requires_physical_presence)
> > +             bioscfg_drv.pending_reboot = true;
> > +
> > +exit_enum_input:
> > +     return ret;
> > +}
> > +
> > +static void update_enumeration_value(int instance_id, char *attr_value)
> > +{
> > +     strscpy(bioscfg_drv.enumeration_data[instance_id].current_value,
> > +             attr_value,
> > +             sizeof(bioscfg_drv.enumeration_data[instance_id].current_value));
> > +}
> > +
> > +ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name_language_code, enumeration);
> > +static struct kobj_attribute enumeration_display_langcode =
> > +             __ATTR_RO(display_name_language_code);
> > +
> > +ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, enumeration);
> > +static struct kobj_attribute  enumeration_display_name =
> > +             __ATTR_RO(display_name);
> > +
> > +ATTRIBUTE_PROPERTY_STORE(current_value, enumeration);
> > +static struct kobj_attribute enumeration_current_val =
> > +     __ATTR_RW_MODE(current_value, 0644);
>
> 0644 is the default for __ATTR_RW(), use that instead.

Done!
>

<snip>




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux