summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
Diffstat (limited to 'samples')
-rw-r--r--samples/cgroup/memcg_event_listener.c2
-rw-r--r--samples/damon/mtier.c11
-rw-r--r--samples/damon/prcl.c11
-rw-r--r--samples/damon/wsse.c15
-rw-r--r--samples/rust/rust_configfs.rs2
-rw-r--r--samples/rust/rust_dma.rs35
-rw-r--r--samples/rust/rust_driver_pci.rs2
-rw-r--r--samples/v4l/v4l2-pci-skeleton.c10
8 files changed, 56 insertions, 32 deletions
diff --git a/samples/cgroup/memcg_event_listener.c b/samples/cgroup/memcg_event_listener.c
index a1667fe2489a..41425edbd88a 100644
--- a/samples/cgroup/memcg_event_listener.c
+++ b/samples/cgroup/memcg_event_listener.c
@@ -18,8 +18,6 @@
#include <sys/inotify.h>
#include <unistd.h>
-#define MEMCG_EVENTS "memory.events"
-
/* Size of buffer to use when reading inotify events */
#define INOTIFY_BUFFER_SIZE 8192
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index beaf36657dea..775838a23d93 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -193,8 +193,6 @@ static void damon_sample_mtier_stop(void)
damon_destroy_ctx(ctxs[1]);
}
-static bool init_called;
-
static int damon_sample_mtier_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -208,7 +206,7 @@ static int damon_sample_mtier_enable_store(
if (enabled == is_enabled)
return 0;
- if (!init_called)
+ if (!damon_initialized())
return 0;
if (enabled) {
@@ -225,7 +223,12 @@ static int __init damon_sample_mtier_init(void)
{
int err = 0;
- init_called = true;
+ if (!damon_initialized()) {
+ if (enabled)
+ enabled = false;
+ return -ENOMEM;
+ }
+
if (enabled) {
err = damon_sample_mtier_start();
if (err)
diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c
index 0226652f94d5..b7c50f2656ce 100644
--- a/samples/damon/prcl.c
+++ b/samples/damon/prcl.c
@@ -122,8 +122,6 @@ static void damon_sample_prcl_stop(void)
}
}
-static bool init_called;
-
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -137,7 +135,7 @@ static int damon_sample_prcl_enable_store(
if (enabled == is_enabled)
return 0;
- if (!init_called)
+ if (!damon_initialized())
return 0;
if (enabled) {
@@ -154,7 +152,12 @@ static int __init damon_sample_prcl_init(void)
{
int err = 0;
- init_called = true;
+ if (!damon_initialized()) {
+ if (enabled)
+ enabled = false;
+ return -ENOMEM;
+ }
+
if (enabled) {
err = damon_sample_prcl_start();
if (err)
diff --git a/samples/damon/wsse.c b/samples/damon/wsse.c
index 21eaf15f987d..799ad4443943 100644
--- a/samples/damon/wsse.c
+++ b/samples/damon/wsse.c
@@ -102,8 +102,6 @@ static void damon_sample_wsse_stop(void)
}
}
-static bool init_called;
-
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -117,10 +115,10 @@ static int damon_sample_wsse_enable_store(
if (enabled == is_enabled)
return 0;
- if (enabled) {
- if (!init_called)
- return 0;
+ if (!damon_initialized())
+ return 0;
+ if (enabled) {
err = damon_sample_wsse_start();
if (err)
enabled = false;
@@ -134,7 +132,12 @@ static int __init damon_sample_wsse_init(void)
{
int err = 0;
- init_called = true;
+ if (!damon_initialized()) {
+ err = -ENOMEM;
+ if (enabled)
+ enabled = false;
+ }
+
if (enabled) {
err = damon_sample_wsse_start();
if (err)
diff --git a/samples/rust/rust_configfs.rs b/samples/rust/rust_configfs.rs
index 5005453f874d..0ccc7553ef39 100644
--- a/samples/rust/rust_configfs.rs
+++ b/samples/rust/rust_configfs.rs
@@ -5,7 +5,7 @@
use kernel::alloc::flags;
use kernel::c_str;
use kernel::configfs;
-use kernel::configfs_attrs;
+use kernel::configfs::configfs_attrs;
use kernel::new_mutex;
use kernel::page::PAGE_SIZE;
use kernel::prelude::*;
diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs
index ead8b542bb4a..4d324f06cc2a 100644
--- a/samples/rust/rust_dma.rs
+++ b/samples/rust/rust_dma.rs
@@ -6,15 +6,19 @@
use kernel::{
device::Core,
- dma::{CoherentAllocation, Device, DmaMask},
- pci,
+ dma::{CoherentAllocation, DataDirection, Device, DmaMask},
+ page, pci,
prelude::*,
+ scatterlist::{Owned, SGTable},
sync::aref::ARef,
};
+#[pin_data(PinnedDrop)]
struct DmaSampleDriver {
pdev: ARef<pci::Device>,
ca: CoherentAllocation<MyStruct>,
+ #[pin]
+ sgt: SGTable<Owned<VVec<u8>>>,
}
const TEST_VALUES: [(u32, u32); 5] = [
@@ -66,21 +70,30 @@ impl pci::Driver for DmaSampleDriver {
kernel::dma_write!(ca[i] = MyStruct::new(value.0, value.1))?;
}
- let drvdata = KBox::new(
- Self {
+ let size = 4 * page::PAGE_SIZE;
+ let pages = VVec::with_capacity(size, GFP_KERNEL)?;
+
+ let sgt = SGTable::new(pdev.as_ref(), pages, DataDirection::ToDevice, GFP_KERNEL);
+
+ let drvdata = KBox::pin_init(
+ try_pin_init!(Self {
pdev: pdev.into(),
ca,
- },
+ sgt <- sgt,
+ }),
GFP_KERNEL,
)?;
- Ok(drvdata.into())
+ Ok(drvdata)
}
}
-impl Drop for DmaSampleDriver {
- fn drop(&mut self) {
- dev_info!(self.pdev.as_ref(), "Unload DMA test driver.\n");
+#[pinned_drop]
+impl PinnedDrop for DmaSampleDriver {
+ fn drop(self: Pin<&mut Self>) {
+ let dev = self.pdev.as_ref();
+
+ dev_info!(dev, "Unload DMA test driver.\n");
for (i, value) in TEST_VALUES.into_iter().enumerate() {
let val0 = kernel::dma_read!(self.ca[i].h);
@@ -95,6 +108,10 @@ impl Drop for DmaSampleDriver {
assert_eq!(val1, value.1);
}
}
+
+ for (i, entry) in self.sgt.iter().enumerate() {
+ dev_info!(dev, "Entry[{}]: DMA address: {:#x}", i, entry.dma_address());
+ }
}
}
diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
index 97baec8df9bc..55a683c39ed9 100644
--- a/samples/rust/rust_driver_pci.rs
+++ b/samples/rust/rust_driver_pci.rs
@@ -79,8 +79,8 @@ impl pci::Driver for SampleDriver {
let drvdata = KBox::pin_init(
try_pin_init!(Self {
- pdev: pdev.into(),
bar <- pdev.iomap_region_sized::<{ Regs::END }>(0, c_str!("rust_driver_pci")),
+ pdev: pdev.into(),
index: *info,
}),
GFP_KERNEL,
diff --git a/samples/v4l/v4l2-pci-skeleton.c b/samples/v4l/v4l2-pci-skeleton.c
index d709d82800cd..69925d30329e 100644
--- a/samples/v4l/v4l2-pci-skeleton.c
+++ b/samples/v4l/v4l2-pci-skeleton.c
@@ -470,7 +470,7 @@ static int skeleton_querystd(struct file *file, void *priv, v4l2_std_id *std)
return 0;
}
-static int skeleton_s_dv_timings(struct file *file, void *_fh,
+static int skeleton_s_dv_timings(struct file *file, void *priv,
struct v4l2_dv_timings *timings)
{
struct skeleton *skel = video_drvdata(file);
@@ -509,7 +509,7 @@ static int skeleton_s_dv_timings(struct file *file, void *_fh,
return 0;
}
-static int skeleton_g_dv_timings(struct file *file, void *_fh,
+static int skeleton_g_dv_timings(struct file *file, void *priv,
struct v4l2_dv_timings *timings)
{
struct skeleton *skel = video_drvdata(file);
@@ -522,7 +522,7 @@ static int skeleton_g_dv_timings(struct file *file, void *_fh,
return 0;
}
-static int skeleton_enum_dv_timings(struct file *file, void *_fh,
+static int skeleton_enum_dv_timings(struct file *file, void *priv,
struct v4l2_enum_dv_timings *timings)
{
struct skeleton *skel = video_drvdata(file);
@@ -544,7 +544,7 @@ static int skeleton_enum_dv_timings(struct file *file, void *_fh,
* can lock but that the DMA engine it is connected to cannot handle
* pixelclocks above a certain frequency), then -ERANGE is returned.
*/
-static int skeleton_query_dv_timings(struct file *file, void *_fh,
+static int skeleton_query_dv_timings(struct file *file, void *priv,
struct v4l2_dv_timings *timings)
{
struct skeleton *skel = video_drvdata(file);
@@ -573,7 +573,7 @@ static int skeleton_query_dv_timings(struct file *file, void *_fh,
return 0;
}
-static int skeleton_dv_timings_cap(struct file *file, void *fh,
+static int skeleton_dv_timings_cap(struct file *file, void *priv,
struct v4l2_dv_timings_cap *cap)
{
struct skeleton *skel = video_drvdata(file);