lkml.org 
[lkml]   [2018]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 2/2] hwmon: ina3221: Read channel input source info from DT
Thank you for the quick response!

On Sat, Sep 22, 2018 at 10:11:26PM -0700, Guenter Roeck wrote:
> >+static umode_t ina3221_attr_is_visible(struct kobject *kobj,
> >+ struct attribute *attr, int n)
> >+{
> >+ const int max_attrs = ARRAY_SIZE(ina3221_attrs) - 1;
> >+ const int num_attrs = max_attrs / INA3221_NUM_CHANNELS;
> >+ struct device *dev = kobj_to_dev(kobj);
> >+ struct ina3221_data *ina = dev_get_drvdata(dev);
> >+ enum ina3221_channels channel = n / num_attrs;
>
> int index = n % num_attrs;
>
> >+ struct ina3221_input *input = &ina->inputs[channel];
> >+ int i;
> >+
> >+ /* Hide if channel input source is disconnected */
> >+ if (input->disconnected)
> >+ return 0;
> >+
> >+ /* Hide label node if label is not provided */
>
> if (index == 1 && !input->label)
> return 0;
>
> and drop i, ina3221_label_attrs[], and the loop below.

Will do that in v5.

Thanks
Nicolin

\
 
 \ /
  Last update: 2018-09-23 07:21    [W:0.058 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site