Re: [PATCH v3 4/4] counter: Add RZ/G2L MTU3 counter driver

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

 



On Tue, Oct 11, 2022 at 03:50:38PM +0000, Biju Das wrote:
> > To support the phase mode selection, implement a Counter device
> > extension for that specific purpose. You can use DEFINE_COUNTER_ENUM()
> > and COUNTER_COMP_DEVICE_ENUM() to create a device extension that will
> > allow users to toggle between "16-bit" and "32-bit" phase modes. If
> > you need help with these macros, just let me know.
> 
> Yes please, that will be helpful. 
> 
> Cheers,
> Biju

It'll look something like this::

    static const char *const rz_mtu3_phase_counting_modes[] = {
            "16-bit",
            "32-bit",
    };
    
    static int rz_mtu3_phase_counting_mode_get(struct counter_device *counter,
                                               u32 *phase_counting_mode);
    static int rz_mtu3_phase_counting_mode_set(struct counter_device *counter,
                                               u32 phase_counting_mode);
    
    static DEFINE_COUNTER_ENUM(rz_mtu3_phase_counting_mode_enum,
                               rz_mtu3_phase_counting_modes);
    
    static struct counter_comp rz_mtu3_device_ext[] = {
            COUNTER_COMP_DEVICE_ENUM("phase_counting_mode",
                                     rz_mtu3_phase_counting_mode_get,
                                     rz_mtu3_phase_counting_mode_set,
                                     rz_mtu3_phase_counting_mode_enum),
    };

Using the get/set callbacks, you can get/set the index for the
respective mode of your rz_mtu3_phase_counting_modes array.

In rz_mtu3_cnt_probe() you could set the counter_device ext member to
rz_mtu3_device_ext. This will make the extensions appear in the sysfs
tree for your Counter device. You should also add a new entry in
Documentation/ABI/testing/sysfs-bus-counter to document this new sysfs
file.

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux