The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/linuxkpi/common/include/linux/kobject.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2010 Isilon Systems, Inc.
    3  * Copyright (c) 2010 iX Systems, Inc.
    4  * Copyright (c) 2010 Panasas, Inc.
    5  * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice unmodified, this list of conditions, and the following
   13  *    disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  *
   29  * $FreeBSD$
   30  */
   31 #ifndef _LINUXKPI_LINUX_KOBJECT_H_
   32 #define _LINUXKPI_LINUX_KOBJECT_H_
   33 
   34 #include <machine/stdarg.h>
   35 
   36 #include <linux/kernel.h>
   37 #include <linux/kref.h>
   38 #include <linux/list.h>
   39 #include <linux/slab.h>
   40 
   41 struct kobject;
   42 struct sysctl_oid;
   43 
   44 #define KOBJ_CHANGE             0x01
   45 
   46 struct kobj_type {
   47         void (*release)(struct kobject *kobj);
   48         const struct sysfs_ops *sysfs_ops;
   49         struct attribute **default_attrs;
   50 };
   51 
   52 extern const struct kobj_type linux_kfree_type;
   53 
   54 struct kobject {
   55         struct kobject          *parent;
   56         char                    *name;
   57         struct kref             kref;
   58         const struct kobj_type  *ktype;
   59         struct list_head        entry;
   60         struct sysctl_oid       *oidp;
   61 };
   62 
   63 extern struct kobject *mm_kobj;
   64 
   65 struct attribute {
   66         const char      *name;
   67         struct module   *owner;
   68         mode_t          mode;
   69 };
   70 
   71 extern const struct sysfs_ops kobj_sysfs_ops;
   72 
   73 struct kobj_attribute {
   74         struct attribute attr;
   75         ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
   76             char *buf);
   77         ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
   78             const char *buf, size_t count);
   79 };
   80 
   81 static inline void
   82 kobject_init(struct kobject *kobj, const struct kobj_type *ktype)
   83 {
   84 
   85         kref_init(&kobj->kref);
   86         INIT_LIST_HEAD(&kobj->entry);
   87         kobj->ktype = ktype;
   88         kobj->oidp = NULL;
   89 }
   90 
   91 void linux_kobject_release(struct kref *kref);
   92 
   93 static inline void
   94 kobject_put(struct kobject *kobj)
   95 {
   96 
   97         if (kobj)
   98                 kref_put(&kobj->kref, linux_kobject_release);
   99 }
  100 
  101 static inline struct kobject *
  102 kobject_get(struct kobject *kobj)
  103 {
  104 
  105         if (kobj)
  106                 kref_get(&kobj->kref);
  107         return kobj;
  108 }
  109 
  110 struct kobject *kobject_create(void);
  111 int     kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
  112 int     kobject_add(struct kobject *kobj, struct kobject *parent,
  113             const char *fmt, ...);
  114 
  115 static inline struct kobject *
  116 kobject_create_and_add(const char *name, struct kobject *parent)
  117 {
  118         struct kobject *kobj;
  119 
  120         kobj = kobject_create();
  121         if (kobj == NULL)
  122                 return (NULL);
  123         if (kobject_add(kobj, parent, "%s", name) == 0)
  124                 return (kobj);
  125         kobject_put(kobj);
  126 
  127         return (NULL);
  128 }
  129 
  130 static inline void
  131 kobject_del(struct kobject *kobj __unused)
  132 {
  133 }
  134 
  135 static inline char *
  136 kobject_name(const struct kobject *kobj)
  137 {
  138 
  139         return kobj->name;
  140 }
  141 
  142 int     kobject_set_name(struct kobject *kobj, const char *fmt, ...);
  143 int     kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
  144             struct kobject *parent, const char *fmt, ...);
  145 
  146 static __inline void
  147 kobject_uevent_env(struct kobject *kobj, int action, char *envp[])
  148 {
  149 
  150         /*
  151          * iwlwifi(4) sends an INACCESSIBLE event when it detects that the card
  152          * (pice endpoint) is gone and it attempts a removal cleanup.
  153          * Not sure if we do anything related to udev/sysfs at the moment or
  154          * need a shortcut or simply ignore it (for now).
  155          */
  156 }
  157 
  158 #endif /* _LINUXKPI_LINUX_KOBJECT_H_ */

Cache object: 9f6efcd253949ed505dffdd7c527ada3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.