Hello! Sorry for my English ;) I am a very newbie in kernel developing.
I am porting linux to Asus P535 (details on
http://www.kaa.org.ua/ru/asus-p535/hardware.html)
I have a GPS-device on COM-port. It switches on after supplying the
electricity (I know the commands sequence for making it). I should call
"open()" function to open the port of this device.
My goal is to create the clear switching on of the GPS-device. I mean,
when "open()" function is called for the GPS-port, the commands for
switching GRP-device on shold be additionally executed. I.e. I should
hang the system hook to the "open()" function and analyze the port, for
which "open()" function was called. If it is the GPS-device port I
should call the function of GPS switching on and after that call the
"open()" function by default. Otherwise, I should just call the "open()"
function by default.
I have gps device on /dev/ttyS1 but to use them need enable it by i2c-tools,
I want write some layer code to auto enable gps device when open()
function executing and shutdown gps when close() called
How make it? What function and structures use me?
I am try to use tty_register_ldisc() but having kernel panic :-)
------------------------------------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/tty.h>
#include <linux/netdevice.h>
#include <linux/poll.h>
#include <linux/ppp_defs.h>
#include <linux/if_ppp.h>
#include <linux/ppp_channel.h>
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <mach/asusp535.h>
static int asusp535_gps_open(struct tty_struct *tty)
{
printk("asusp535_gps_open() %s\n", tty->name);
gpio_set_value(GPIO_ASUSP535_GPS_PWR1, 1);
gpio_set_value(GPIO_ASUSP535_GPS_PWR2, 1);
return(0);
}
static void asusp535_gps_close(struct tty_struct *tty)
{
printk("asusp535_gps_close() %s\n", tty->name);
gpio_set_value(GPIO_ASUSP535_GPS_PWR2, 0);
gpio_set_value(GPIO_ASUSP535_GPS_PWR1, 0);
}
static int asusp535_gps_hangup(struct tty_struct *tty)
{
printk("asusp535_gps_hangup() %s\n", tty->name);
return(0);
}
static struct tty_ldisc_ops asusp535_gps_ldisc = {
.owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC,
.name = "gps",
.open = asusp535_gps_open,
.close = asusp535_gps_close,
.hangup = asusp535_gps_hangup,
};
static int __init asusp535_gps_init(void)
{
int err = tty_register_ldisc(N_TTY, &asusp535_gps_ldisc);
printk("asusp535_gps_init()\n");
if(err)
printk(KERN_ERR "asusp535_gps: error %d registering line disc.\n", err);
return(err);
}
static void __exit asusp535_gps_cleanup(void)
{
printk("asusp535_gps_cleanup()\n");
if(tty_unregister_ldisc(N_TTY))
printk(KERN_ERR "asusp535_gps: failed to unregister line discipline\n");
}
module_init(asusp535_gps_init);
module_exit(asusp535_gps_cleanup);
MODULE_LICENSE("GPL");
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html