All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Section Mismatch
@ 2009-04-10 20:22 Wayne Call
  2009-04-11 20:18 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Call @ 2009-04-10 20:22 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]

I get the following "Section mismatch" warnings when attempting to build the
lm73_rtdm.c and lpl_twi_uart_rtdm.c drivers.  What causes a mismatch?

 

 

WARNING: arch/blackfin/mach-bf537/boards/lm73_rtdm.o - Section mismatch:
reference to .init.data:_device_tmpl from .text between
'_rt_lm73_sensor_device_create' (at offset 0x108) and
'_rt_lm73_sensor_ioctl'

WARNING: arch/blackfin/mach-bf537/boards/lm73_rtdm.o - Section mismatch:
reference to .init.data:_device_tmpl from .text between
'_rt_lm73_sensor_device_create' (at offset 0x114) and
'_rt_lm73_sensor_ioctl'

WARNING: arch/blackfin/mach-bf537/boards/lpl_twi_uart_rtdm.o - Section
mismatch: reference to .init.data:_device_tmpl from .text after
'_rt_lpl_twi_uart_device_create' (at offset 0x298)

WARNING: arch/blackfin/mach-bf537/boards/lpl_twi_uart_rtdm.o - Section
mismatch: reference to .init.data:_device_tmpl from .text after
'_rt_lpl_twi_uart_device_create' (at offset 0x2a4)

 

 

The "Section mismatch" might be related to the following code?

 

 
static const struct rtdm_device __initdata device_tmpl = {
    struct_version:     RTDM_DEVICE_STRUCT_VER,
 
    device_flags:       RTDM_NAMED_DEVICE | RTDM_EXCLUSIVE,
    device_name:        "",
    open_rt:            rt_lm73_sensor_open,
    ops: {
        close_rt:       rt_lm73_sensor_close,
        ioctl_rt:       rt_lm73_sensor_ioctl,
    },
    device_class:       RTDM_CLASS_LM73,
    driver_name:        "lm73_sensor_rtd",
    driver_version:     RTDM_DRIVER_VER(1, 0, 0),
    peripheral_name:    "i2c_lm73",
    provider_name:      "LonePeakLabs.Inc",
};

 

 

Wayne

 


[-- Attachment #2: Type: text/html, Size: 8169 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Section Mismatch
  2009-04-10 20:22 [Xenomai-help] Section Mismatch Wayne Call
@ 2009-04-11 20:18 ` Gilles Chanteperdrix
  2009-04-13 21:24   ` Wayne Call
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2009-04-11 20:18 UTC (permalink / raw)
  To: wcall; +Cc: xenomai

Wayne Call wrote:
> I get the following "Section mismatch" warnings when attempting to build the
> lm73_rtdm.c and lpl_twi_uart_rtdm.c drivers.  What causes a mismatch?

Yes, these are plain Linux debugging messages, completely unrelated to
Xenomai. they tell you that you access object from the init/exit
sections from the text section, which is bad, since the init/exit
sections may not be always available when functions from the text
section are running. Show us the full code, and probably someone will be
able to tell you what the problem is.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Section Mismatch
  2009-04-11 20:18 ` Gilles Chanteperdrix
@ 2009-04-13 21:24   ` Wayne Call
  2009-04-13 22:09     ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Call @ 2009-04-13 21:24 UTC (permalink / raw)
  To: xenomai

The code that causes a mismatch is posted below.

Wayne


/***************************************************************************
 *   Copyright (C) 2009 by Lone Peak Labs, Inc.                            *
 *   wcall@domain.hid
*
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
***************************************************************************/

#include <linux/kernel.h>
#include <linux/ctype.h>
#include <xenomai/rtdm/rtdm_driver.h>
#include <linux/i2c.h>
#include <linux/lm73.h>
#include <asm/mach-bf537/lm73_rtdm.h>

#define COMPILE_LPL_DEBUG_KERNEL    1
#include <linux/lplDebug.h>



// Store pointer for sensor device
static rtlm73_sensor_device_t  *m_lm73Dev[2];
static int                      m_lm73Count;



/////////////////////////////////////////
// rt_lm73_sensor_open
//   Open the real time device
// 
static int rt_lm73_sensor_open(struct rtdm_dev_context *context,
rtdm_user_info_t *user_info, int oflags)
{
    LPL_DEBUG_KERNEL("rt_lm73_sensor_open", oflags, %d);
    return 0;
}


/////////////////////////////////////////
// rt_lm73_sensor_close
//   Close the real time device
// 
static int rt_lm73_sensor_close(struct rtdm_dev_context *context,
rtdm_user_info_t *user_info)
{
    LPL_DEBUG_KERNEL("rt_lm73_sensor_close", user_info, %p);
    return 0;
}


/////////////////////////////////////////
// rt_lm73_sensor_ioctl
//   Read from or write to the real time device
// 
static int rt_lm73_sensor_ioctl(struct rtdm_dev_context *context,
rtdm_user_info_t *user_info, int request, void *umem)
{
    u32                     kmem[1];
    rtlm73_sensor_device_t *dev     = container_of(context->device,
rtlm73_sensor_device_t, rtd);
    lm73_sensor_t          *lm73_sensor_pointer;

    LPL_DEBUG_KERNEL("rt_lm73_sensor_ioctl", request, %d);
    LPL_DEBUG_KERNEL("rt_lm73_sensor_ioctl", umem, %p);

    lm73_sensor_pointer = &dev->lm73_sensor_data;    

    LPL_DEBUG_KERNEL("rt_lm73_sensor_ioctl", lm73_sensor_pointer->address,
%#x);
    LPL_DEBUG_KERNEL("rt_lm73_sensor_ioctl", dev->rtd.device_name, %s);

    switch (request)
    {
        // Temperature read?
	    case TEMPERATURE_READ:
            kmem[0] =
lm73_retrieve_temperature(lm73_sensor_pointer->address);
            LPL_DEBUG_KERNEL("TEMPERATURE_READ", kmem[0], %#x);
            return rtdm_safe_copy_to_user(user_info, umem, kmem,
sizeof(u32));

	    case SET_TEMPERATURE_READ_RATE:
            rtdm_safe_copy_from_user(user_info, kmem, umem, sizeof(signed
int));
            lm73_approximate_temperature_read_rate(kmem[0]);
            LPL_DEBUG_KERNEL("SET TEMPERATURE_READ_RATE", kmem[0], %#x);
            return 0;
	}             
                   	                 	
    return -1;//no such op, need to find the right op code for this.
}


static const struct rtdm_device __initdata device_tmpl = {
    struct_version:     RTDM_DEVICE_STRUCT_VER,

    device_flags:       RTDM_NAMED_DEVICE | RTDM_EXCLUSIVE,
    device_name:        "",
    open_rt:            rt_lm73_sensor_open,
    ops: {
        close_rt:      	rt_lm73_sensor_close,
        ioctl_rt:       rt_lm73_sensor_ioctl,
    },
    device_class:       RTDM_CLASS_LM73,
    driver_name:        "lm73_sensor_rtd",
    driver_version:     RTDM_DRIVER_VER(0, 0, 1),
    peripheral_name:    "i2c_lm73",
    provider_name:      "LonePeakLabs.Inc",
};


int rt_lm73_sensor_device_create(const char *name, u16 address)
{
    int                     deviceSize      =
sizeof(rtlm73_sensor_device_t);
    int                     errorRegister;
    rtlm73_sensor_device_t *dev             =
kmalloc(sizeof(rtlm73_sensor_device_t), GFP_KERNEL);

    // Insert the address
    dev->lm73_sensor_data.address = address;

    LPL_DEBUG_KERNEL("rt_lm73_sensor_device_create",
dev->lm73_sensor_data.address, %d);
    LPL_DEBUG_KERNEL("rt_lm73_sensor_device_create", name, %s);
    LPL_DEBUG_KERNEL("rt_lm73_sensor_device_create", deviceSize, %d);

    memcpy(&dev->rtd, &device_tmpl, sizeof(struct rtdm_device));
    // Insert the name
    strncpy(dev->rtd.device_name, name, RTDM_MAX_DEVNAME_LEN);
    dev->rtd.proc_name = name;

    LPL_DEBUG_KERNEL("rt_lm73_sensor_device_create", dev->rtd.proc_name,
%s);

    // Register the device
    errorRegister = rtdm_dev_register(&dev->rtd);
    if (errorRegister)
    {
        LPL_DEBUG_KERNEL("rt_lm73_sensor_device_create", errorRegister, %d);
        printk("couldn't register rtlm73_sensor device %s\n",
dev->rtd.device_name);	
        kfree(dev);
        return -1;
    }
    printk("Registering LM73 RTDM %s at address %#x\n",
dev->rtd.device_name, dev->lm73_sensor_data.address);

    m_lm73Dev[m_lm73Count] = dev;
    m_lm73Count++;

    return 	0;	
}


int __init lm73_sensor_rtdm_init(void)
{
	printk("Hello LM73 RTDM Driver v0.0.1\n");
    m_lm73Count = 0;
	rt_lm73_sensor_device_create("lm73_sensor1",
LPL_LM73_SENSOR_1_ADDRESS);
	rt_lm73_sensor_device_create("lm73_sensor2",
LPL_LM73_SENSOR_2_ADDRESS);

    return 0;
}


void __exit lm73_sensor_rtdm_exit(void)
{
	printk("Goodbye LM73 RTDM Driver\n");
    // Unregister the two LM73 Sensors
	rtdm_dev_unregister(&m_lm73Dev[0]->rtd, 0);
    rtdm_dev_unregister(&m_lm73Dev[1]->rtd, 0);
}


MODULE_AUTHOR("Wayne Call<wcall@domain.hid>");
MODULE_DESCRIPTION("LM73 RTDM driver");
MODULE_LICENSE("GPL");

module_init(lm73_sensor_rtdm_init);
module_exit(lm73_sensor_rtdm_exit);



-----Original Message-----
From: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org] 
Sent: Saturday, April 11, 2009 2:19 PM
To: wcall@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Section Mismatch

Wayne Call wrote:
> I get the following "Section mismatch" warnings when attempting to build
the
> lm73_rtdm.c and lpl_twi_uart_rtdm.c drivers.  What causes a mismatch?

Yes, these are plain Linux debugging messages, completely unrelated to
Xenomai. they tell you that you access object from the init/exit
sections from the text section, which is bad, since the init/exit
sections may not be always available when functions from the text
section are running. Show us the full code, and probably someone will be
able to tell you what the problem is.

-- 
					    Gilles.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Section Mismatch
  2009-04-13 21:24   ` Wayne Call
@ 2009-04-13 22:09     ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2009-04-13 22:09 UTC (permalink / raw)
  To: wcall; +Cc: xenomai

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

Wayne Call wrote:
> The code that causes a mismatch is posted below.
> 

...

> 
> 
> static const struct rtdm_device __initdata device_tmpl = {

The rtdm_device structure passed to rtdm_dev_register must be available
as long as the device is registered, not just during init (see
documentation). Besides the fact that you modify the device_name
in-place already, also RTDM will write to this struct. So 'const' is not
appropriate here, too.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-13 22:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-10 20:22 [Xenomai-help] Section Mismatch Wayne Call
2009-04-11 20:18 ` Gilles Chanteperdrix
2009-04-13 21:24   ` Wayne Call
2009-04-13 22:09     ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.