我为我们开发的外围设备编写了一个平台驱动程序,并希望向sysfs公开一些配置选项.我已设法使用属性结构(见下文)和sysfs_create_file探测函数创建适当的文件,但我无法弄清楚如何将show/store函数附加到平台驱动程序中的结构.
我在网上找到的大多数资源使用了一个device_attribute结构或类似的东西来创建他们的文件,这也适合吗?还有另一种方法可以为平台驱动程序执行此操作吗?
我的属性struct看起来像这样:
struct attribute subkey_attr = {
.name = "subkeys",
.mode = S_IWUGO | S_IRUGO,
};
Run Code Online (Sandbox Code Playgroud)
我使用此调用注册该文件:
riddler_kobject = &pdev->dev.kobj;
ret_val = sysfs_create_file(riddler_kobject, &subkey_attr);
Run Code Online (Sandbox Code Playgroud) 在我添加TextViews的过程中,我有一个带有LinearLayout的ScrollView.但我总是希望最后添加的TextView可见,所以当添加TextView时,我需要ScrollView滚动到Bottom.我不知道为什么,但是当我在添加textview之后调用scrollto(),scrollby()或fullScroll()时,它只会在最后一个之前滚动到textview.
你知道更好的方法吗?
非常感谢!
码:
我有一个Button,它调用了这个函数:
private void addRound() {
// TODO Auto-generated method stub
TextView newRound = new TextView(Stopwatch.this);
newRound.setText("" + counter + ". - " + timerText());
newRound.setTextSize(20);
newRound.setGravity(Gravity.CENTER);
linlay.addView(newRound);
counter++;
}
Run Code Online (Sandbox Code Playgroud)
调用此函数后,我调用fullScroll().
addRound();
sv.fullScroll(View.FOCUS_DOWN);
Run Code Online (Sandbox Code Playgroud)
sv是我的ScrollView,linlay是scrollview中的linearlayout.