mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 23:03:57 -04:00
This follow-up patch completes centralization of kselftest.h and ksefltest_harness.h includes in remaining seltests files, replacing all relative paths with a non-relative paths using shared -I include path in lib.mk Tested with gcc-13.3 and clang-18.1, and cross-compiled successfully on riscv, arm64, x86_64 and powerpc arch. [reddybalavignesh9979@gmail.com: add selftests include path for kselftest.h] Link: https://lkml.kernel.org/r/20251017090201.317521-1-reddybalavignesh9979@gmail.com Link: https://lkml.kernel.org/r/20251016104409.68985-1-reddybalavignesh9979@gmail.com Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com> Suggested-by: Andrew Morton <akpm@linux-foundation.org> Link: https://lore.kernel.org/lkml/20250820143954.33d95635e504e94df01930d0@linux-foundation.org/ Reviewed-by: Wei Yang <richard.weiyang@gmail.com> Cc: David Hildenbrand <david@redhat.com> Cc: David S. Miller <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Günther Noack <gnoack@google.com> Cc: Jakub Kacinski <kuba@kernel.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Mickael Salaun <mic@digikod.net> Cc: Ming Lei <ming.lei@redhat.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Simon Horman <horms@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
83 lines
1.9 KiB
C
83 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
* media_device_open.c - Media Controller Device Open Test
|
|
*
|
|
* Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
|
|
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* This file adds a test for Media Controller API.
|
|
* This test should be run as root and should not be
|
|
* included in the Kselftest run. This test should be
|
|
* run when hardware and driver that makes use Media
|
|
* Controller API are present in the system.
|
|
*
|
|
* This test opens user specified Media Device and calls
|
|
* MEDIA_IOC_DEVICE_INFO ioctl, closes the file, and exits.
|
|
*
|
|
* Usage:
|
|
* sudo ./media_device_open -d /dev/mediaX
|
|
*
|
|
* Run this test is a loop and run bind/unbind on the driver.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/stat.h>
|
|
#include <linux/media.h>
|
|
|
|
#include "kselftest.h"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int opt;
|
|
char media_device[256];
|
|
int count = 0;
|
|
struct media_device_info mdi;
|
|
int ret;
|
|
int fd;
|
|
|
|
if (argc < 2) {
|
|
printf("Usage: %s [-d </dev/mediaX>]\n", argv[0]);
|
|
exit(-1);
|
|
}
|
|
|
|
/* Process arguments */
|
|
while ((opt = getopt(argc, argv, "d:")) != -1) {
|
|
switch (opt) {
|
|
case 'd':
|
|
strncpy(media_device, optarg, sizeof(media_device) - 1);
|
|
media_device[sizeof(media_device)-1] = '\0';
|
|
break;
|
|
default:
|
|
printf("Usage: %s [-d </dev/mediaX>]\n", argv[0]);
|
|
exit(-1);
|
|
}
|
|
}
|
|
|
|
if (getuid() != 0)
|
|
ksft_exit_skip("Please run the test as root - Exiting.\n");
|
|
|
|
/* Open Media device and keep it open */
|
|
fd = open(media_device, O_RDWR);
|
|
if (fd == -1) {
|
|
printf("Media Device open errno %s\n", strerror(errno));
|
|
exit(-1);
|
|
}
|
|
|
|
ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi);
|
|
if (ret < 0)
|
|
printf("Media Device Info errno %s\n", strerror(errno));
|
|
else
|
|
printf("Media device model %s driver %s\n",
|
|
mdi.model, mdi.driver);
|
|
}
|