Re: [PATCH v2 3/3] Bluetooth: hci_vhci: Add force_prevent_wake entry

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

 



Hi Marcel,

On Wed, Sep 29, 2021 at 6:53 AM Marcel Holtmann <marcel@xxxxxxxxxxxx> wrote:
>
> Hi Luiz,
>
> > This adds force_prevent_wake which can be used to force a certain state
> > while interacting with force_suspend.
> >
> > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
> > ---
> > drivers/bluetooth/hci_vhci.c | 48 ++++++++++++++++++++++++++++++++++++
> > 1 file changed, 48 insertions(+)
> >
> > diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
> > index 52f9106faeae..60a408a49828 100644
> > --- a/drivers/bluetooth/hci_vhci.c
> > +++ b/drivers/bluetooth/hci_vhci.c
> > @@ -137,6 +137,51 @@ static const struct file_operations force_suspend_fops = {
> >       .llseek         = default_llseek,
> > };
> >
> > +static bool prevent_wake;
>
> this needs to be in vhci_data since it should be per vhci.

Ack.

> > +
> > +static ssize_t force_prevent_wake_read(struct file *file, char __user *user_buf,
> > +                                    size_t count, loff_t *ppos)
> > +{
> > +     char buf[3];
> > +
> > +     buf[0] = prevent_wake ? 'Y' : 'N';
> > +     buf[1] = '\n';
> > +     buf[2] = '\0';
> > +     return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
> > +}
> > +
> > +static bool hci_debugfs_prevent_wake(struct hci_dev *hdev)
> > +{
> > +     return prevent_wake;
> > +}
>
> The hci_debugfs prefix here is rather misleading. This is vhci_prevent_wake actually. And just move it to a more closer position with all the other hdev-> callbacks.

Ack.

> > +
> > +static ssize_t force_prevent_wake_write(struct file *file,
> > +                                     const char __user *user_buf,
> > +                                     size_t count, loff_t *ppos)
> > +{
> > +     struct hci_dev *hdev = file->private_data;
> > +     bool enable;
> > +     int err;
> > +
> > +     err = kstrtobool_from_user(user_buf, count, &enable);
> > +     if (err)
> > +             return err;
> > +
> > +     if (prevent_wake == enable)
> > +             return -EALREADY;
> > +
> > +     hdev->prevent_wake = hci_debugfs_prevent_wake;
>
> You need to set these with the other hdev-> callback and not in debugfs callback.

Will do and also change its naming as well.

> > +
> > +     return count;
> > +}
> > +
> > +static const struct file_operations force_prevent_wake_fops = {
> > +     .open           = simple_open,
> > +     .read           = force_prevent_wake_read,
> > +     .write          = force_prevent_wake_write,
> > +     .llseek         = default_llseek,
> > +};
> > +
> > static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
> > {
> >       struct hci_dev *hdev;
> > @@ -198,6 +243,9 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
> >       debugfs_create_file("force_suspend", 0644, hdev->debugfs, hdev,
> >                           &force_suspend_fops);
> >
> > +     debugfs_create_file("force_prevent_wake", 0644, hdev->debugfs, hdev,
> > +                         &force_prevent_wake_fops);
> > +
>
> Regards
>
> Marcel
>


-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux