how to extend existing kernel module about optional functionality - good practise
by DeanAnderson from LinuxQuestions.org on (#4YAKS)
Hi
I am trying to extend implementation of power managment driver adm1275.c:
https://github.com/torvalds/linux/bl...mbus/adm1275.c
about reset framework functionality as pulse on one of the pin of this device causes board reset.
I did it by simply extending adm1275.c file. However I have a doubt if this is good practise. Because please see how the configuration of device looks in device tree:
Code:&i2c12
{
adm1075: adm1075@18 {
compatible = "adi,adm1075";
reg = <0x18>;
#reset-cells = <0>; /*when present functionality is turned on*/
};
};When you use reset framework the good practise is to name node as for example:
Code:reset_ctl: reset-controller{...}so from device tree it is known what it serves for.
So I should change the name in device tree to for example:
Code:&i2c12
{
por_rst_ctl: reset-controller@18 {
compatible = "adi,adm1075";
reg = <0x18>;
#reset-cells = <0>; /*when present functionality is turned on*/
};
};But the driver do much more than reset the board. It serves for many other purposes - monitoring voltage, so from this point of view the name is misleading.
I think that such complex driver in which there are many functionalities should be programmed in the way somehow:
Code:&i2c12
{
adm1075: adm1075@18 {
compatible = "adi,adm1075";
reg = <0x18>;
por_rst_ctl: reset_controller{
compatible = "adi,reset-ctl";
#reset-cells = <0>; /*when present functionality is turned
on*/}
};
};and I am rigth looking at implementation of:
drivers/mfd/syscon.c
drivers/reset/reset-ti-syscon.c


I am trying to extend implementation of power managment driver adm1275.c:
https://github.com/torvalds/linux/bl...mbus/adm1275.c
about reset framework functionality as pulse on one of the pin of this device causes board reset.
I did it by simply extending adm1275.c file. However I have a doubt if this is good practise. Because please see how the configuration of device looks in device tree:
Code:&i2c12
{
adm1075: adm1075@18 {
compatible = "adi,adm1075";
reg = <0x18>;
#reset-cells = <0>; /*when present functionality is turned on*/
};
};When you use reset framework the good practise is to name node as for example:
Code:reset_ctl: reset-controller{...}so from device tree it is known what it serves for.
So I should change the name in device tree to for example:
Code:&i2c12
{
por_rst_ctl: reset-controller@18 {
compatible = "adi,adm1075";
reg = <0x18>;
#reset-cells = <0>; /*when present functionality is turned on*/
};
};But the driver do much more than reset the board. It serves for many other purposes - monitoring voltage, so from this point of view the name is misleading.
I think that such complex driver in which there are many functionalities should be programmed in the way somehow:
Code:&i2c12
{
adm1075: adm1075@18 {
compatible = "adi,adm1075";
reg = <0x18>;
por_rst_ctl: reset_controller{
compatible = "adi,reset-ctl";
#reset-cells = <0>; /*when present functionality is turned
on*/}
};
};and I am rigth looking at implementation of:
drivers/mfd/syscon.c
drivers/reset/reset-ti-syscon.c