Sorry for the insistence but I can not see how to update the variable
when i write the variable to the file. Only I miss this part of the
thesis and I have little time and I'm really locked it.
I saw the function "ieee80211_if_parse_tsf" and i reproduce them for
energy variable but without success. I have a lot of doubts about the
cycle and the trigger to read the file.

This is my code:
static ssize_t ieee80211_if_fmt_energy(
   const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
{
   struct ieee80211_local *local = sdata->local;
   u64 energy;

   energy = local->remain_energy;

   return scnprintf(buf, buflen, "0x%016llx\n", (unsigned long long) energy);
}

static ssize_t ieee80211_if_parse_energy(
   struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
{
   struct ieee80211_local *local = sdata->local;
   unsigned int energy;

   if (local->ops->set_energy) {
       local->remain_energy=energy;
       wiphy_info(local->hw.wiphy,
           "debugfs set ENERGY");
   }

   ieee80211_recalc_dtim(local, sdata);
   return buflen;
}
IEEE80211_IF_FILE_RW(energy);

But with this code i didn't create any file, for the "initialization".
I'm really blocked on this :(

Thanks a lot,
Carlos Meralto

2015-10-12 16:17 GMT+01:00 Bob Copeland <[email protected]>:
> On Mon, Oct 12, 2015 at 02:18:19PM +0100, Carlos Meralto wrote:
>> Hi Bob,
>>
>> I don't understand the: "When you write to the file from userspace,
>> you would then update some (new) battery level variable"
>> I create the file with "debugfs_create_file("energy", 0777, phyd,
>> &filevalue, &fops_debug);" But the question is about update the
>> variable when i write to the file from userspace, is any command to do
>> that?
>
> http://lxr.free-electrons.com/source/net/mac80211/debugfs_netdev.c?v=4.0#L452
>
> That file is an example of updating a state variable whenever userspace
> writes to the file (the tsf value is passed to drv_set_tsf() which the driver
> may write into hardware, but in principle you could do anything here).
>
> The implementation of the debugfs file (that you write) is responsible
> for taking the value written and updating some variable (that you
> create) somewhere.
>
> --
> Bob Copeland %% http://bobcopeland.com/
_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

Reply via email to