X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=wrapper%2Fgenhd.h;h=98feb57bebde635fb11781209ca2871a8faafa0c;hb=3bd6ac3e83874adf006a1bc46d94d8880fc197c8;hp=70b8d3fe6f3cdfd28349675b3ba40fda857a76f1;hpb=e36de50dd09527901339797a61a0a40d241c1a6d;p=lttng-modules.git diff --git a/wrapper/genhd.h b/wrapper/genhd.h index 70b8d3fe..98feb57b 100644 --- a/wrapper/genhd.h +++ b/wrapper/genhd.h @@ -1,7 +1,5 @@ -#ifndef _LTTNG_WRAPPER_GENHD_H -#define _LTTNG_WRAPPER_GENHD_H - -/* +/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) + * * wrapper/genhd.h * * wrapper around block layer functions and data structures. Using @@ -9,55 +7,18 @@ * kernel that exports this function to GPL modules. * * Copyright (C) 2011-2014 Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; only - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef _LTTNG_WRAPPER_GENHD_H +#define _LTTNG_WRAPPER_GENHD_H + #include -#ifdef CONFIG_KALLSYMS +#ifdef CONFIG_KALLSYMS_ALL #include #include -static inline -char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf) -{ - char *(*disk_name_sym)(struct gendisk *hd, int partno, char *buf); - - disk_name_sym = (void *) kallsyms_lookup_funcptr("disk_name"); - if (disk_name_sym) { - return disk_name_sym(hd, partno, buf); - } else { - printk_once(KERN_WARNING "LTTng: disk_name symbol lookup failed.\n"); - return NULL; - } -} - -#else - -static inline -char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf) -{ - return disk_name(hd, partno, buf); -} - -#endif - -#ifdef CONFIG_KALLSYMS_ALL - static inline struct class *wrapper_get_block_class(void) { @@ -71,6 +32,19 @@ struct class *wrapper_get_block_class(void) return ptr_block_class; } +/* + * Canary function to check for 'block_class' at compile time. + * + * From 'include/linux/genhd.h': + * + * extern struct class block_class; + */ +static inline +struct class *__canary__get_block_class(void) +{ + return &block_class; +} + static inline struct device_type *wrapper_get_disk_type(void) { @@ -84,6 +58,16 @@ struct device_type *wrapper_get_disk_type(void) return ptr_disk_type; } +/* + * No canary for 'disk_type', it's only defined in 'block/genhd.c'. + * + * static inline + * struct device_type *__canary__get_disk_type(void) + * { + * return &disk_type; + * } + */ + #else static inline